forked from: forked from: Singleton
forked from forked from: Singleton (diff: 6)
ActionScript3 source code
/**
* Copyright 9re ( http://wonderfl.net/user/9re )
* MIT License ( http://www.opensource.org/licenses/mit-license.php )
* Downloaded from: http://wonderfl.net/c/jL0q
*/
// forked from yd_niku's forked from: Singleton
// forked from kamipoo's Singleton
package {
import flash.display.Sprite;
import flash.text.TextField;
public class FlashTest extends Sprite {
public function FlashTest() {
// write as3 code here..
//var singleton:Singleton = Singleton.getInstance();
// internal keyword is available from the same package
var singleton:Singleton = new Singleton(new SingletonInternal);
}
}
}
class Singleton {
public function Singleton(key: SingletonInternal) {
if(! key ) {
throw new ArgumentError("error");
}
}
public static function getInstance():Singleton {
return SingletonInternal.instance;
}
}
internal class SingletonInternal {
public static var instance: Singleton = new Singleton(new SingletonInternal ());;
}