PDA

View Full Version : Event.COMPLETE not firing



Icy Penguin
March 19th, 2008, 05:28 PM
Hey all,

I have a simple image loader trying to load an image with an Event Listener.

The COMPLETE event never fires however.

If I use Event.ENTER_FRAME, for example, the image loads in there just fine (but is done so hundreds of times, of course).




...


private var imageLoader:Loader;
var request:URLRequest;

private function loadImage() {
request = new URLRequest(itemData[itemId][3]);
imageLoader = new Loader();
imageLoader.addEventListener(Event.COMPLETE, imageComplete);
imageLoader.load(request);
}
public function imageComplete(event:Event) {
addChild(imageLoader);
}

...



public const any_help_appreciated:Boolean = true;

:)

Anogar
March 19th, 2008, 05:31 PM
If you listen for progress (ProgressEvent.PROGRESS) do you get reports?

Krilnon
March 19th, 2008, 05:37 PM
Shouldn't you be adding the listener to the contentLoaderInfo property of the Loader?

Icy Penguin
March 19th, 2008, 05:40 PM
Nope. Used this code: (don't know if I did it right)




import flash.events.ProgressEvent;
..
imageLoader.addEventListener(ProgressEvent.PROGRES S, imageProgress);
..

public function imageProgress(event:Event) {
trace("Wheeee")
}

Icy Penguin
March 19th, 2008, 05:41 PM
@Krilnon: what's contentLoaderInfo?

:)

Icy Penguin
March 19th, 2008, 05:42 PM
I read something about Garbage Collection eating up the event listeners and such - but the subsequent garble didn't make much sense to me.

Icy Penguin
March 19th, 2008, 05:44 PM
Changed the progress code and I get two "Whee"s in the output.



imageLoader.contentLoaderInfo.addEventListener(Pro gressEvent.PROGRESS, imageProgress);
public function imageProgress(event:ProgressEvent) {
trace("Wheeee")
}


EDIT: And adding 'contentLoaderInfo' to the Event.COMPLETE works just fine.

Thanks :)