Skip to content

Instantly share code, notes, and snippets.

@schonstal
Created May 29, 2013 23:05
Show Gist options
  • Save schonstal/5674536 to your computer and use it in GitHub Desktop.
Save schonstal/5674536 to your computer and use it in GitHub Desktop.
AS3 singleton example
package
{
public class G
{
public var _paused:Boolean;
private static var _instance:G = null;
private static function get instance():G {
if(_instance == null) {
_instance = new G();
_instance._paused = false;
}
return _instance;
}
public static function get paused():Boolean {
return instance._paused;
}
public static function set paused(value:Boolean):void {
instance._paused = value;
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment