Skip to main content
Participant
September 19, 2008
Question

Loading and unloading swf

  • September 19, 2008
  • 1 reply
  • 353 views
I am making a site and I want each button to load an swf, which would be the content of each page. When I click on each button the swf will load, however, the old swf will not go away. how does one do this. Thanks.
This topic has been closed for replies.

1 reply

Participating Frequently
September 19, 2008
It looks like you are adding the newly loaded swf, but not removing the old one. So, maybe this change would help:
function about_CLICK(myevent:MouseEvent):void{
var loadMain:Loader = new Loader();
loadMain.load(new URLRequest("clip0.swf"));
// if there is a child on the display list remove it
if (getChildAt(0) !=null) removeChildAt(0);
stage.addChild(loadMain);
}

I should mention, however, that there is a bug in Flash 9 related to unloading swfs: http://www.gskinner.com/blog/archives/2008/04/failure_to_unlo.html

However, I don't think this is affecting your visible behavior.
willsmattAuthor
Participant
September 19, 2008
I got no code errors but instead of removing the SWFs as they appears it just removes buttons and the bg everytime I clicked an event.