Skip to main content
Inspiring
June 5, 2009
Question

why is my loader not throwing an Event.COMPLETE when loaded?

  • June 5, 2009
  • 1 reply
  • 740 views

hi all,

I've got a loader that I put an event listener on for Event.COMPLETE.  I then add it as child of the stage and call the load method.  The swf it's loading appears on the stage, but the Event.COMPLETE listener is never called.  I can attach a MouseEvent.CLICK event to the loader and that works just fine.  Am I doing something wrong?  Any help is greatly appreciated!

package {
    import flash.display.MovieClip;
    import flash.net.URLRequest;
    import flash.events.*;
    import flash.display.Loader;

    public class LoadBig extends MovieClip{

        private var thing:Loader;  
       
        public function LoadBig() { // CONSTRUCTOR           
            thing = new Loader();           
            thing.addEventListener(Event.COMPLETE, thing_loaded);  

            thing.addEventListener(MouseEvent.CLICK, thing_clicked);     
            thing.load(new URLRequest('big.swf'));           
            addChild(big_thing);
        }
       
        private function thing_clicked(e:MouseEvent):void{  // THIS FUNCTION WORKS FINE
            trace('thing was clicked.');
        }
       
        private function thing_loaded(e:Event):void{  // THIS FUNCTION IS NEVER CALLED?!
            trace('thing is loaded.');
        }
    }       
}

This topic has been closed for replies.

1 reply

June 5, 2009

The event is not dispatched from the loader instance. Add the handler to loader.contentLoaderInfo.

thing.contentLoaderInfo.addEventListener(Event.COMPLETE, thing_loaded); 

Inspiring
June 5, 2009

thanks!  I'd forgotten about the contentLoaderInfo . . .

June 5, 2009

You're welcome.