Created
December 19, 2012 17:32
-
-
Save amowu/4338579 to your computer and use it in GitHub Desktop.
Get Class by external load .swf
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package { | |
import flash.display.Sprite; | |
import flash.display.Loader; | |
import flash.display.LoaderInfo; | |
import flash.net.URLRequest; | |
import flash.display.MovieClip; | |
import flash.events.Event; | |
import flash.system.ApplicationDomain; | |
public class GetClassBySWF { | |
private var swfPath:String = "YOUR_SWF_PATH.swf"; | |
private var loader:Loader; | |
private var ur:URLRequest; | |
public function SunNeon() | |
{ | |
ur = new URLRequest(swfPath); | |
loader = new Loader(); | |
loader.contentLoaderInfo.addEventListener(Event.COMPLETE, onComplete); | |
loader.load(ur); | |
} | |
private function onComplete(event:Event):void{ | |
var swfTarget:LoaderInfo = event.target as LoaderInfo; | |
var appDomain:ApplicationDomain = swfTarget.applicationDomain as ApplicationDomain; | |
var YOUR_CLASS:Class = appDomain.getDefinition("YOUR_CLASS_NAME") as Class; | |
var mc:MovieClip = new YOUR_CLASS() as MovieClip; | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment