Matt Kenefick
Contact Me Experiments Blog Portfolio

Actionscript to Android

Over the next few weeks.. I’m going to write out some very simple to progressively more advanced Actionscript to Android comparisons. Since it’s all Java based, it should be fairly simple to see the differences and merge your way from AS3 to Android. Instead of explaining a bunch of stuff, I’ll just jump directly into it.

Actionscript 3.0

package com.android.hello {
 
  import android.app.Activity;
  import android.os.Bundle;
  import android.widget.TextView;
 
  public class HelloAndroid extends Activity{
    /** Called when activity is first created */
    public override onCreate( savedInstanceState:Bundle ):void {
      super.onCreate( savedInstanceState );
 
      var tv:TextView = new TextView( this );
      tv.setText("Hello, Android");
      setContentView( tv );
    }
  }
}
Android (Java)

package com.android.hello;
 
  import android.app.Activity;
  import android.os.Bundle;
  import android.widget.TextView;
 
  public class HelloAndroid extends Activity {
    /** Called when the activity is first created. */
    @Override
    public void onCreate( Bundle savedInstanceState ) {
       super.onCreate( savedInstanceState );
 
       TextView tv = new TextView(this);
       tv.setText("Hello, Android");
       setContentView(tv);
    }
}

This is a very simple example that helps show the differences in syntax.

Actionscript 3 Android (Java)
- Enclose package in brackets
- Override after “public”
- Return type (void) AFTER parameters
- Variable type “var varname:Type”
- Do not enclose package
- Override set before method
- Return type (void) BEFORE method name
- Variable type “Type varname”

Tags: , , ,

3 Responses to “Actionscript to Android”

  1. gino8080 Says:

    Thank you very useful and simple explanation, so i’ll go for android ASAP i can get a Android phone!! :D

  2. Weekly Shared Items – 15. September, 2009 | TOXIN LABS - weblog of a german design student from wuerzburg Says:

    [...] Actionscript to Android [...]

  3. Hello mobile world « Jufa Says:

    [...] and for Flash devs: Actionscript to Android [...]

Leave a Reply