Safari Books Online is a digital library providing on-demand subscription access to thousands of learning resources.
Loading Data N OT E If you want your usage of the Loader and CustomLoader classes to be as similar as possible, so you can switch between them with as few edits as possi- ble, you can still enable verbose tracing without loading the asset immediately. You can set up your code like the custom JPG loading example, so the load() method is used separately--just like using the Loader class. However, when instantiating CustomLoader (line 3 in the example), just pass in null and true as the parameter values: newCustomLoader(null,true); This will enable verbose logging, but will not invoke the load() method in the class constructor. 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 jpgLoaderInfo.addEventListener(ProgressEvent.PROGRESS, onProgress, false,0,true); functiononProgress(evt:Event):void{ progressBar.scaleX=evt.target.loader.percentLoaded; } functiononComplete(evt:Event):void{ evt.target.removeEventListener(Event.COMPLETE,onComplete); evt.target.loader.removeListeners(); addChild(evt.target.content); } functioncreateProgressBar():Sprite{ varsp:Sprite=newSprite(); varg:Graphics=sp.graphics; g.beginFill(0x00FF00); g.drawRect(0,0,100,10); g.endFill(); sp.x=sp.y=10; returnsp; } Loading Data