Adobe Air‎ > ‎

JavaとAS3の比較

データ型

 Java AS3
 byte int
 short int
 int int
 long Number
 char uint
 float Number

クラス定義

 Java AS3
 package test;
 import hoge.Test1;
 public class MyClass {

 }
  package test {
    import hoge.Test1;
    public class MyClass {

    }
 }

GetterとSetter

 Java AS3
 private int count = 0;

 public int getCount() {
   return count;
 }

 public void setCount(int count) {
   this.count = count;
 }

 public void run() {
   int i = getCount();
   setCount(i + 1);
 }

 private _count:int = 0;

 public function get count():int {
   return _count;
 }

 public function set count(count:int) {
    _count = count;
 }

 public function run():void {
   var i:int = count;
   count = i + 1;
 }

その他もろもろ

 Java  AS3
 int i = 0
 var i:int = 0
 public static int SIZE = 1
 public const SIZE:int = 1
 public void run()
 public function run():void
 String value = (String) obj
 value:String = obj as String
 value:String = String(obj)
 int[] list = new int[3]  var list:Array = new Array(3)
 int[] list = {1, 2, 3}  var list:Array = [1, 2, 3]
 if (obj instanceof String)
 if (obj is String)
 System.out.println("a")  trace("a")
 int[] list = {1, 2, 3}
 for ( int i : list) {
 }
 var list:Array = [1, 2, 3]   
 for (var i in list) {
 }
 MyObj[] list;
 for (MyObj o : list) {
 }
 var list:Array;
 for each (var o:MyObj in list) {
 }
 String value = "a";
 if (value.equals("b")) {
 }
 var value:String = "a";
 if (value == "b") {
 }
 public static void test()
 static public function test():void
 private List<String> list;
[ArrayElementType("String")]
private list:Array;
※パッケージ名からの修飾が必要
@Deprecated
public void deprecatedMethod();
[Deprecated]
public function deprecatedMethod:void();

メタデータタグについては以下にドキュメントがある。
http://livedocs.adobe.com/flex/3_jp/html/help.html?content=metadata_3.html
Comments