PDA

View Full Version : How do I find the LoaderInfo's related object?


matbury
12-05-2007, 01:43 AM
I don't know if this is even possible, or if I'm going the right way about this.

Here's what I've got:

loader.contentLoaderInfo.addEventListener(Progress Event.PROGRESS, imageProgressHandler);

function imageProgressHandler(event:ProgressEvent):void {
var percent:uint = Math.floor(event.bytesLoaded / event.bytesTotal * 100);
trace(event.target); // output - [object LoaderInfo]
}

What's the path from LoaderInfo to loader? (LoaderInfo doesn't recognise 'parent') Or how can I get to loader in this function?

matbury
12-05-2007, 01:50 AM
I tried this:

trace(event.target.loader);

And I got this:

Error: Error #2099: The loading object is not sufficiently loaded to provide this information.
at flash.display::LoaderInfo/get loader()
at PhotoGallery/::imageProgressHandler()

If I try it on the Event.COMPLETE or Event.INIT events it works fine:

trace(event.target.loader.parent); // [object Sprite]

Is there a way of accessing the parent Sprite before it's finished loading?

ivanparas
12-05-2007, 05:07 AM
Is there a way of accessing the parent Sprite before it's finished loading?

The whole point of adding the loader info listeners is so that you don't try to access the object before it's finished loading.

runtime
07-02-2009, 04:12 PM
trace(event.target.loader.parent); // [object Sprite]


Hey on an unrelated note, this little nugget helped me find the parent of loaderInfo. and Luckily for me i needed it the onComplete.

I guess I'm two years behind the times, lol.