Skip to main content
Known Participant
January 16, 2010
Answered

unload swfs

  • January 16, 2010
  • 1 reply
  • 2312 views

hello all,


i have been trying to solve this for two days now, and nothing has helped me..

i have a menu, that works with a xml file.
the xml has the specific code that triggers the .as file:

HTML Code:
<buttons>
     <button name="HOME" linkType="custom" link="home.swf" />
     <button name="ABOUT" linkType=" _custom" link="about.swf" />
     <button name="BLOG" linkType=" _self" link="contact.html" />
    <button name="CONTACT" linkType=" _self" link="contact.html" />
 
</buttons>
now, on the .as file, i have to load the movies:

var request:URLRequest = new URLRequest(link);
var loader:Loader = new Loader()
loader.load(request)
var swfContainer:MovieClip=new MovieClip ;
this.addChild(swfContainer)
swfContainer.addChild(loader);;

when i press the button home for example, the home will load...
then i press the button about, and it loads as well, but the home still playing on the back...
how do i make the content for home to disapear when another button is clicked?

because the code works for all the buttons, it has to be something generic .. that would work for the event of anybutton being clicked..

any suggestions?

totally appreciate it.
This topic has been closed for replies.
Correct answer kglad

i thought i could use the load/unload in the each individual frames... but i hear you cant place code in the frames, i am getting an error message that says:

1180: Call to a possibly undefined method addFrameScript.  ... package}

and it wont even load... i was going to insert the unloadAndStop code after

var imageRequest:URLRequest = new URLRequest("p2.swf");
var imageLoader:Loader = new Loader();
imageLoader.load(imageRequest);
addChild(imageLoader);

but it is not working.

should i start another tread with the question of how can i load/unload in the individual frames?  or is this still part of the question?

thanks a bunch,

roberta


the 1180 error is a result of you making your document class extend the sprite class.  have it extend the movieclip class and you can attach code to frames.

1 reply

kglad
Community Expert
Community Expert
January 16, 2010

if you're publishing for flash player 10, you can use the unloadAndStop() method of your loader, IF you apply that before over-writing your previous loader:


var loader:Loader

function whateverF(link:String){

var request:URLRequest = new URLRequest(link);

if(loader!=null){

loader.unloadAndStop();

}

loader = new Loader()

loader.load(request)

var swfContainer:MovieClip=new MovieClip ;

this.addChild(swfContainer)

swfContainer.addChild(loader);

}

pi09Author
Known Participant
January 16, 2010

thank you so much for replying, but i am still confused...

in regards to your last comment.. "IF you apply that before over-writing your previous loader:"

sorry im a total newbie, and trying to learn it.  Thank you so much for your patience!!