/ Published in: ActionScript 3

Global.GetInstance().SomeFunction();
Expand |
Embed | Plain Text
package { public class Global { private static var m_instance:Global = null; public function Global( enforcer:SingletonEnforcer ) { if (enforcer == null) { throw Error("Singleton Enforcer Not Valid. Multiple Instances Not Allowed."); } } public static function GetInstance():Global { if (m_instance == null) { m_instance = new Global( new SingletonEnforcer() ); } return m_instance; } } } class SingletonEnforcer{}
Comments

You need to login to post a comment.
where can I learn more about Singleton?