Hi,
This can be useful
ActionScript Code: package { import flash.display.LoaderInfo; import flash.display.Loader; import flash.display.MovieClip; import flash.net.URLRequest; import flash.events.Event; import flash.events.EventDispatcher; public class library extends EventDispatcher { public static var $assets:LoaderInfo; public function library(url:String):void { var request:URLRequest = new URLRequest(url); var loader:Loader = new Loader(); loader.contentLoaderInfo.addEventListener(Event.COMPLETE, onLoaded); loader.load(request); } private function onLoaded(e:Event):void { $assets = LoaderInfo(e.target); dispatchEvent( new Event("ON_LIBRARY_LOADED")) } public static function getElement(id:String):MovieClip { var src = $assets.applicationDomain.getDefinition(id) as Class; return MovieClip(new src()); } }}var myLibrary:library = new library("assets.swf");myLibrary.addEventListener("ON_LIBRARY_LOADED", InitializeStage)public function InitializeStage(e:Event) { var sqr= library.getElement("sqr_mc"); addChild(sqr)}
Dynamic Shared library class
Friday, May 25, 2012
[Action Script] Dynamic Shared library class May,2012
Posted by Bimo Hery Prabowo at 3:13 AM
Subscribe to:
Post Comments (Atom)
0 comments:
Post a Comment