I’m putting together a flash project where when a button is clicked on the menu it loads in a swf . Well I ran into a snag and dont know the best way to go about making it so when I click another menu option the old swf file unloads. As it know it loads the new swf file on top of the old. Here is a section of my menu code that loads in a swf file.
about_button.addEventListener(MouseEvent.ROLL_OVER,aboutOver);
about_button.addEventListener(MouseEvent.ROLL_OUT,aboutOut);
about_button.addEventListener(MouseEvent.CLICK,aboutClick);
function aboutOver(event:MouseEvent):void{
about_button.gotoAndPlay(“on”
;
}
function aboutOut(event:MouseEvent):void{
about_button.gotoAndPlay(“off”
;
}
function aboutClick(event:MouseEvent):void{
// Turn off other button animations
home_button.gotoAndStop(“off”
;
portfolio_button.gotoAndStop(“off”
;
contact_button.gotoAndStop(“off”
;
}
// Turn back on Event Listeners for other buttons
home_button.addEventListener(MouseEvent.ROLL_OUT,homeOut);
portfolio_button.addEventListener(MouseEvent.ROLL_OUT,portOut);
contact_button.addEventListener(MouseEvent.ROLL_OUT,contactOut);
about_button.removeEventListener(MouseEvent.ROLL_OUT,aboutOut);
about_button.gotoAndPlay("on");
//load in content
var thisLoader:Loader = new Loader();
thisLoader.contentLoaderInfo.addEventListener(Event.COMPLETE,doneLoading);
thisLoader.load(new URLRequest("about.swf"));
function doneLoading(event:Event):void{
contentHolder.addChild(thisLoader);
}
Now i know i can use the removeChild() to remove the movie clip since basicly the swfs are being loaded into a movie clip as a content holder. But since the function when click runs all the code for loading in the swf file that is making the scope swf load local to that function only correct?
So what im looking for is some advice samples, etc from someone that might have a good solution to remove the old swf before the new one is loaded in?
Posted 2 months ago