In case Flash no longer exists; a copy of this site is included in the Flashpoint archive's "ultimate" collection.

Dead Code Preservation :: Archived AS3 works from wonderfl.net

forked from: Singleton

Get Adobe Flash player
by yd_niku 12 Nov 2009
/**
 * 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 ());; 
}