Posted
Filed under Action Script

[원문]http://www.campjohn.dk/wp/?p=820


생성 하고 넘겨 주는 방식..

var _theParameterFromURL:String = String(root.loaderInfo.parameters.whatParameter);
var _tempPercent:Number;
var _loader:Loader = new Loader();

_loader.contentLoaderInfo.addEventListener(ProgressEvent.PROGRESS, isloading);
_loader.contentLoaderInfo.addEventListener(Event.COMPLETE, finishedLoading);

_loader.load(new URLRequest("howtograb.swf"));

function isloading(e:ProgressEvent):void {
            _tempPercent = e.bytesLoaded / e.bytesTotal;
            thePercent.text = String(Math.floor(_tempPercent*100))+"%";
}

function finishedLoading(e:Event):void {
            removeChildAt(0);
            _tempPercent = null;
            addChild(_loader);

            Object(_loader.content).init(_theParameterFromURL);
}




---------------------------------------------------------------------------------------'

package {
           
            import flash.display.Sprite;
            import flash.text.TextField;

           
            public class howtograb extends Sprite {
                       
                        private var _theTextFromURL:String;
                                               
                        public function howtograb():void {
                                    //
                        }
                       
                        public function init(someURL:String):void {
                                    _theTextFromURL = someURL;
                                   
                                    theText.text = _theTextFromURL;
                        }
                       
            }
}

2011/07/04 19:58 2011/07/04 19:58