I am working on an app. that has a main app. window with tree
control that is used to load other applications into the main
window. I want to be able to reuse as much code as possible. For
that I want to keep generic AS code in the main application. Also
there are many data sources that in use by multiple applications.
For example, a list of US states used for dropdowns.
I would want to load this data into main application only
once and then dynamically assign to data controls.
Can someone share ideas of doing development in such facion?
There are of course lots of ways to do this. Our approach has
been to use singleton classes to hold common data and common
The instance is declared as Static so there is only one copy.
public class SomeSingleton
private static var _instance:SomeSingleton;
private var _someData:ArrayCollection;
public function SomeSingleton()
public static function getInstance():SomeSingleton
if(_instance == null)
_instance = new SomeSingleton();
public function set someData(v:ArrayCollection):void
_someData = v;
public function get someData():ArrayCollection
To use this anywhere in your flex app just get the instance
and invoke it's methods.
SomeSingleton.getInstance().someData = new