Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>a) Create Singleton class. You can share data between classes.<br> Like this</p> <p>CustomSingleton.as</p> <pre><code>package modules.custom { public class CustomSingleton { private var _g_data1: String; private var _g_data2: String; private var _g_object1: Object; public function CustomSingleton(internally:SingletonInternal) { super(); if(internally == null) { throw new Error("Must use getInstance() Method."); } } public static function getInstance():CustomSingleton { return SingletonInternal.instance; } public function set g_data1(value:String):void { _g_data1 = value; } public function get g_data1():String { return _g_data1; } public function set g_data2(value:String):void { _g_data2 = value; } public function get g_data2():String { return _g_data2; } public function set g_object1(value:Object):void { _g_object1 = value; } public function get g_object1():Object { return _g_object1; } } } import modules.custom.CustomSingleton; class SingletonInternal{ public static var instance:CustomSingleton = new CustomSingleton(new SingletonInternal()); public function SingletonInternal(){} } </code></pre> <p>Component1.as</p> <pre><code>public class Component1 { private var singleton: CustomSingleton = CustomSingleton.getInstance(); public function hoge(): void { singleton.g_data1 = "aaa"; } } </code></pre> <p>Component2.as</p> <pre><code>public class Component2 { private var singleton: CustomSingleton = CustomSingleton.getInstance(); public function hoge(): void { trace(singleton.g_data1); singleton.g_data1 = "bbb"; } } </code></pre> <p>b)Create Hello world app.<br> <a href="http://blog.air4android.com/2011/07/10/hello-world-air-for-android/" rel="nofollow">http://blog.air4android.com/2011/07/10/hello-world-air-for-android/</a></p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload