Skip to main content
Known Participant
August 2, 2011
Answered

loader unload event not calling

  • August 2, 2011
  • 1 reply
  • 541 views

hi friends

my code is

try {
    if (MovieClip(this.parent)!=null) {
        if (MovieClip(this.parent).imagename!=null) {
            var t=MovieClip(this.parent).imagename;
            var url:URLRequest=new URLRequest(t);
            var ldr:Loader = new Loader();
            ldr.load(url);
            ldr.contentLoaderInfo.addEventListener(Event.COMPLETE,onLoadingComplete);
            ldr.contentLoaderInfo.addEventListener(Event.UNLOAD, unloadimages);
            imgholder.addChild(ldr)

            function onLoadingComplete(e:Event):void {
                var targetLoader:Loader=Loader(e.target.loader);
                targetLoader.content.height=140;
                targetLoader.content.width=180;
                dispatchEvent(e);
            }
            function unloadimages(event:Event):void {
                for (var childcounter:uint = 0; childcounter < imgholder.numChildren; childcounter++) {
                    var object:Object=imgholder.getChildAt(childcounter);
                    imgholder.removeChildAt(childcounter);
                }
                //while (imgholder.numChildren > 0){ imgholder.removeChildAt(0);}
                ldr.contentLoaderInfo.removeEventListener(Event.UNLOAD, unloadimages);
                imgholder.removeChild(ldr);
                ldr.unload();
                ldr=null;
            }
        }

    }
} catch (e:Error) {
    trace(" Load Big Image " + e);
}

my loder unload event not calling>>??

This topic has been closed for replies.
Correct answer Ned Murphy

You should probably move all except the command to load outside of that try section.  Aside from that, I do not see anything that would trigger unloading, thus nothing to trigger the UNLOAD event.

1 reply

Ned Murphy
Ned MurphyCorrect answer
Legend
August 2, 2011

You should probably move all except the command to load outside of that try section.  Aside from that, I do not see anything that would trigger unloading, thus nothing to trigger the UNLOAD event.

Known Participant
August 2, 2011

thnx Ned Murphy for replay

so can u tell me what and where i can write to call UNLOAD event in my code

Ned Murphy
Legend
August 2, 2011

Not really, I have no idea when you intend to unload or how you intend to trigger it.   YOu should be able to figure that out though.  One thing is for certain... you can't have it happen like you have it where the unload command occurs in that function that it would end up calling after the unload command occurs... can you see that?