Home Tutorials Forums Articles Blogs Movies Library Employment Press
Old 11-20-2009, 08:45 PM   #1
Join Date: Dec 2006
Posts: 3
Default help with AS3/ unloading external swf file

I have external swf files load and play on main swf with button click but need to find out how to close with just mouse click. Here's the code so far:

var img1Request:URLRequest = new URLRequest ("kelly.swf");
var img1Loader:Loader = new Loader();
kelly_mc.addEventListener(MouseEvent.CLICK, clickF);

function clickF(event:MouseEvent):void{
img1Loader.contentLoaderInfo.addEventListener(Even t.COMPLETE,loadNowF);
function loadNowF(event:Event):void{
sasimotion is offline   Reply With Quote
Old 11-20-2009, 09:00 PM   #2
Join Date: Aug 2008
Posts: 141

Have you tried calling container_mc.removeChild(img1Loader)?
stenrap is offline   Reply With Quote
Old 11-20-2009, 09:11 PM   #3
Join Date: Dec 2006
Posts: 3

Thanks for your suggestion. yes, I tried that and got the following error:
1120: Access of undefined property img1loader.
sasimotion is offline   Reply With Quote
Old 11-20-2009, 09:36 PM   #4
Site Contributor
Mazoonist's Avatar
Join Date: Jun 2006
Posts: 3,160
Send a message via AIM to Mazoonist

The compiler is case sensitive. So be careful of your spelling and capitalization:
(image1Loader vs. image1loader <-- see any difference there???).

removeChild doesn't unload anything, it only removes it from the display list. The loaded item will still be in memory, ready to display again with the next addChild.

To remove items from memory altogether, use the unload() method of the Loader class. Or, if you are going to be loading mutiple items one at a time, consider just using the same loader instance again. No need to unload what's there, just use it to load something else, and the former thing will automatically be unloaded.
My Tutorials * My Website
Mazoonist is offline   Reply With Quote

Thread Tools
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

All times are GMT. The time now is 06:34 AM.

Follow actionscriptorg on Twitter


Powered by vBulletin® Version 3.8.5
Copyright ©2000 - 2014, Jelsoft Enterprises Ltd.
Ad Management plugin by RedTyger
Copyright 2000-2013 ActionScript.org. All Rights Reserved.
Your use of this site is subject to our Privacy Policy and Terms of Use.