PDA

View Full Version : LoaderInfo and ProgressEvent.PROGRESS



maguskrool
February 14th, 2008, 04:53 PM
Hi.

I'm working on a project where I have to preload several .swfs. I created a custom class (myLoader) that extends the Loader class and adds it a few string variables with data I need. To each instance's contentLoaderInfo I add event listeners for ProgressEvent.PROGRESS and assign the same event handler function.

The problem is, I need to access the myLoader instance from the event handler, but so far I haven't been able to, not until it finishes loading.

I'm not an expert on the AS3 event model, but the ProgressEvent.PROGRESS is not a bubbling event so I don't think I can listen to it from the Loader instance itself, for example.

I'm really stumped with this, don't know why the LoaderInfo object can't access the Loader immediately, since the Loader instance creates it in the first place. The url property returns "null" also.

Any help in this matter is very appreciated.



//Event handler.
private function _progressHandler ($evt:ProgressEvent):void {
trace ($evt.target);
trace ($evt.currentTarget); // both return [object LoaderInfo]

trace ($evt.target.loader);
trace ($evt.currentTarget.loader); //both return Error #2099: The loading object is not sufficiently loaded to provide this information.

trace ($evt.target.url);
trace ($evt.currentTarget.url); //both return null
}

onecommoncode
February 14th, 2008, 05:07 PM
Well from looking at the error message its telling you, you cannot access that information until it has finished loading. I think you have to use Event.INIT, but I could be wrong.