Hi Friends,
Was wondering how to reference a singleton instance for particular Module in flex..
after reading few blog and googling ..
found a solution/rather built upon it .. thought this might be helpful to somebody…
Most things in AS are built on Java so Looked at Java Mulitone >> and there is the solution…
import flash.utils.Dictionary;
public class InternalModelLocator
{
private static var instances:Dictionary= new Dictionary();//Dictionary is treated as Java Hash Map
public function InternalModelLocator()
{
/* Only One Instance created with GetInstanceMethod*/
}
/* module_uuid can be a String --------
In case of PureMVC "multitonKey" (this.multitonKey) can be used as unique key for multiple modules
*/
public static function getInstance(module_uuid:String):InternalModelLocator
{
var instance:InternalModelLocator = instances[module_uuid];
if(instance == null)
{
instance = new InternalModelLocator();
instances[module_uuid] = instance;
}
return instance;
}
}
Let me know if I miss some thing or needs more elboration….
No comments:
Post a Comment