forked from: Singleton

by yd_niku forked from Singleton (diff: 17)
♥1 | Line 21 | Modified 2009-11-12 20:33:36 | MIT License
play

ActionScript3 source code

/**
 * Copyright yd_niku ( http://wonderfl.net/user/yd_niku )
 * MIT License ( http://www.opensource.org/licenses/mit-license.php )
 * Downloaded from: http://wonderfl.net/c/wd7r
 */

// forked from kamipoo's Singleton
package {
    import flash.display.Sprite;
    public class FlashTest extends Sprite {
        public function FlashTest() {
            // write as3 code here..
            var singleton:Singleton = Singleton.getInstance();
        }
    }
}

class Singleton {
    public function Singleton(key: SingletonInternal) {
        if(! key ) {
            new ArgumentError("error");
        }
    }
    
    public static function getInstance():Singleton {
        return SingletonInternal.instance;
    }
    
}

internal class SingletonInternal {
    public static var instance: Singleton = new Singleton(new SingletonInternal ());; 
}

Forked