Skip to main content
Participant
July 27, 2011
Answered

Can't unload a Loader =(

  • July 27, 2011
  • 1 reply
  • 381 views

I can't seem to be able to figure out how to unload a JPG image once I've loaded it so I can load a second JPG in it's place. Here's my code so far (document class, picHolder_mc exists already on the timeline). All that happens is the second JPG being called loads on top of the first. Any help greatly appreciated.

import flash.display.*;
import flash.events.*;
import flash.net.*

public var pdfA_Loader:Loader = new Loader();

public var pdfA_URL:URLRequest;

public var picHolder_mc:MovieClip;      // mc on timeline

public function loadJPG():void {

     pdfA_Loader.unload();
     pdfA_URL = new URLRequest("myJPG.jpg");
     pdfA_Loader.load(pdfA_URL);
     picHolder_mc.addChild(pdfA_Loader)    

}

This topic has been closed for replies.
Correct answer kglad

one loader can only load one object at any one time.  so, if you see more than one displayobject they can't both be loaded by one loader.

you either have a 2nd loader somewhere or you're duplicating what you see that's loaded by one loader (eg, using the bitmapdata class'es draw method).

1 reply

kglad
Community Expert
Community Expert
July 27, 2011

why are those public variables?

is there another pdfA_Loader = new Loader() statement in any class/timeline?

johntealAuthor
Participant
July 27, 2011

No, no others

kglad
Community Expert
kgladCommunity ExpertCorrect answer
Community Expert
July 27, 2011

one loader can only load one object at any one time.  so, if you see more than one displayobject they can't both be loaded by one loader.

you either have a 2nd loader somewhere or you're duplicating what you see that's loaded by one loader (eg, using the bitmapdata class'es draw method).