/ Published in: ActionScript 3
URL: http://www.destroyyourcomputer.com
Easily create a SINGLE USE ONLY (Singleton) Class Object with this template.
Expand |
Embed | Plain Text
package { public class Example { private static var instance:Example; public function Example(access:Access){ if (access != null) { if (Example.instance == null){ Example.instance = this; } } else { throw new Error(”Illegal operation”); } } //provides access to singleton instance public static function getInstance():Example{ if (instance == null){ instance = new Example(); } return Example; } } }
Comments
Subscribe to comments
You need to login to post a comment.

this is incorrect in several areas and would never work as is.
It should be this:
I've renamed example to Functions (as thats how i needed it) package {
}
class Access {}