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

flash on 2010-10-4

Get Adobe Flash player
by uly 04 Oct 2010
    Embed
/**
 * Copyright uly ( http://wonderfl.net/user/uly )
 * MIT License ( http://www.opensource.org/licenses/mit-license.php )
 * Downloaded from: http://wonderfl.net/c/gSdI
 */

package {
    import flash.system.SecurityDomain;
    import flash.net.URLRequest;
    import flash.display.MovieClip;
    import flash.system.LoaderContext;
    import flash.display.Loader;
    import flash.display.Sprite;
    import flash.system.ApplicationDomain;
    import flash.events.Event;
    import flash.display.DisplayObject;
    import flash.system.Security;
    

    public class ApplicationDomainTest extends Sprite {
        private var _loader:Loader;
        private var _loadMC:MovieClip;
        public function ApplicationDomainTest() {
            // write as3 code here..
            Security.allowDomain("powari.com");
            addEventListener(Event.ADDED_TO_STAGE,_initialize,false,0,true);
        }
        
        private function _initialize(e:Event):void{
            removeEventListener(Event.ADDED_TO_STAGE,_initialize,false);
            _loader = new Loader();
            _loader.contentLoaderInfo.addEventListener(Event.INIT,_onComplete,false,0,true);
            _loader.load(new URLRequest("http://powari.com/applicationdomaintest.swf"),new LoaderContext(true,ApplicationDomain.currentDomain,SecurityDomain.currentDomain));
        
        }
        
        private function _onComplete(e:Event):void{
            e.currentTarget.removeEventListener(Event.INIT,_onComplete,false);
            trace(_loader.contentLoaderInfo.applicationDomain);
            if(e.currentTarget.applicationDomain.hasDefinition("TestView")){
                var clazz:Class = e.currentTarget.applicationDomain.getDefinition("TestView") as Class;
                _loadMC = new clazz() as MovieClip;
                addChild(_loadMC as DisplayObject);
                _loadMC.x = 100;
                _loadMC.y = 100;
                trace(_loadMC);
                trace(_loadMC.circle);
                
            }
            //trace(e.currentTarget.applicationDomain);

        }


    }
}