-
Help with loading/unloading .swf
Ok, here is what i got. I have it working somewhat. I have one scene that plays. 4 buttons are on screen, when i click a button i want it to load a .swf file and it does but the old scene is still on screen. So it's basically playing 2 scenes at once and i don't want it to. I want it to unload the old scene and play the new scene.
Here is my code.
Actionscript Code:
import flash.events.MouseEvent; import flash.net.URLRequest;
stop();
var myLoader:Loader = new Loader(); about_mc.addEventListener(MouseEvent.CLICK, page2content); function page2content(myevent:MouseEvent):void { var myURL:URLRequest=new URLRequest("page2.swf"); myLoader.load(myURL); addChild(myLoader); }; myLoader.addEventListener(MouseEvent.CLICK, unloadcontent); function unloadcontent(myevent:MouseEvent):void { removeChild(myLoader); about_mc.gotoAndPlay(1); }
-
Registered User
hi,
You can use unload().
-
Originally Posted by nunomira
Thanks, yeah i've tried that. Tried unload(); and UnloadAndStop();
Both of them bring me the same result. I've got it working halfway. It loads the other swfs onto the stage and will unload once i click on it again but the 1st swf isn't unloading like i want i to. I want the 1st swf to unload once i click on the button.
So the question is... how do i get the 1st swf to unload, get it off the stage? Why is not unloading?
This is what i got so far
code: import flash.events.MouseEvent;
import flash.net.URLRequest;
stop();
var myLoader:Loader = new Loader();
about_mc.addEventListener(MouseEvent.CLICK, page2content);
function page2content(myevent:MouseEvent):void {
var myURL:URLRequest=new URLRequest("page2.swf");
myLoader.load(myURL);
addChild(myLoader);
};
myLoader.addEventListener(MouseEvent.CLICK, unloadcontent);
function unloadcontent(myevent:MouseEvent):void {
removeChild(myLoader);
myLoader.unloadAndStop();
//gotoAndPlay(1);
}
Last edited by dex26; 03-10-2011 at 03:14 PM.
-
Hi,
if you want to remove completely the movieClip from memory, you need to remove all eventListeners also.
this is the cleanest version i think you can get from it:
http://goo.gl/f17IS
--
there is a place for those who dare to dream...
Flash Developer
VISTAPARK GMBH
BÄRENSTRASSE 11-13
D-42117 WUPPERTAL
-
Originally Posted by ifmi
Hi,
if you want to remove completely the movieClip from memory, you need to remove all eventListeners also.
this is the cleanest version i think you can get from it:
http://goo.gl/f17IS
Thanks very much, i'm going to play with that tomorrow. I'll let you know how it goes.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|