Hi Susan,

Check out the documention for the Loader() Class - you'll find that the loaded swf is a child of the loader.

AS3 won't unload instances while there are any references to them. You can try unloading the loader - it won't be unloadable while the 'i' variable is refering to the instance. I think it will be eligible for GC once I has been pointed at a new Loader instance.

It's usually helpful to type variables and give them meaningful names - for example var i = new Loader() might be written as var swfLoader:Loader = new Loader();

This will make the code easier to follow especially since the compiler will know what the variable refers to (since you've specified the class) and can make sure that the variable is used correctly. I usually expect variables called 'i' to be counters of some kind.

Good luck!

Paul


----- Original Message ----- From: "Lord, Susan, CTR, DSS" <[EMAIL PROTECTED]>
To: "Flash Coders List" <[email protected]>
Sent: Tuesday, September 02, 2008 4:53 PM
Subject: [Flashcoders] Unloading an SWF in Flash and controlling the loadedSWF



Hi there,

I have a newbie question for you. I posted this to the newbie list and
recieved no response. I am wondering if it might be too advanced for
that  list. For those of you who are on both lists, please excuse the
double post.

I have a pop-up box that I am loading as an external swf, using the
following code:

function displayHotword(evt:Event):void {
trace("in function");
var i =new Loader();
addChild(i);
i.load(new URLRequest("hotword.swf"));
i.scaleX = 1;
i.scaleY = 1;
i.x = 100;
i.y = 150
;
}
btClassified.addEventListener(MouseEvent.CLICK, displayHotword);


I am not sure how to unload the movie. I am also not sure on how to
control the movie when it is on the screen. In AS2, I always used a
movie holder so I had an instance... with this method, I don't know what
the movie instance would be.

Right now to close the loaded SWF, I am using following code within the
loaded swf file.

function closeHotword(evt:Event):void {
this.visible=false;

}
btClose.addEventListener(MouseEvent.CLICK, closeHotword);

And simply making it invisible from the swf file.

I am wondering if there is a better way to do this?  It seems like this
would cause some memory issues eventually as each time the student will
click on the link to load pop-up window, it would create a new instance
of the movie and just hide it, instead of unloading it.

I am new to AS3 and not sure how to approach this.

Any help you could provide is appreciated!

Thanks!




_______________________________________________
Flashcoders mailing list
[email protected]
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders


_______________________________________________
Flashcoders mailing list
[email protected]
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders

Reply via email to