To register for an Internet.com membership to receive newsletters and white papers, use the Register button ABOVE.
To participate in the message forums BELOW, click here


A Flash Developer Resource Site

Go Back   Flash Kit Community Forums > Flash Help > Actionscript 3.0

Reply
 
Thread Tools Rate Thread Display Modes
Old 07-11-2007, 08:22 PM   #1
mswallace
Matthew Wallace Web Developmen
 
Join Date: Jul 2007
Location: Spring Hill, TN
Posts: 3
Question addChild and loadMovie help please

K,

I am switching to AS3 and I need some help understanding something.

I normally like to have an empty MC that I load external swf files into when I am working on a project.

In AS2 I would do it like this.

myButton.onRelease = function(){
myemptyMC.loadMovie("myswf.swf");
}

Now the cool thing about that was if I loaded a different swf file into the empty movieclip it would just replace the swf that was loaded in before it.

No in as the to load a swf I have to create a new loader and URLRequest. I totally understand how to do that. My problem is that using addChild() does not replace the swf that is already loaded into the empty MC it just places another instance of the new swf file that is being loaded in on top of the swf file that is there.

so if I do myemptyMC.addChild(mySwfLoader); does not replace the content of that movieclip.

How do I do that or how do I remove the content of the movieclip in order to load in my new swf file?

thank
mswallace is offline   Reply With Quote
Old 07-11-2007, 09:12 PM   #2
tariqm
Member
 
Join Date: Jun 2006
Location: Florida, USA
Posts: 78
There is a very simple solution for this!

create a variable that does not get destroyed(global kinda). If your using the CS3 interface just place it in the actionscript part of the stage. If your using the sdk to compile just make it a private var in your class.
After setting it for the first time add it to the myemptyMC object.

when you want to make that variable something else just reference it(set it) to another object.

Example


Code:
var child:Object=mySwfLoader;
myEmptyMC.addChild(child);

//this changes it to a new thing because I'm setting child which is already added to the MovieClip to something new
child=new Object();
Hope this helped !

If not just ask about what you don't understand.
tariqm is offline   Reply With Quote
Old 07-11-2007, 09:23 PM   #3
mswallace
Matthew Wallace Web Developmen
 
Join Date: Jul 2007
Location: Spring Hill, TN
Posts: 3
That should work

Thanks I will give that a try. That should work.

thanks,
Matthew
mswallace is offline   Reply With Quote
Old 07-11-2007, 10:14 PM   #4
AfternoonDelite
Senior Member
 
Join Date: Jan 2006
Location: USA
Posts: 383
Let's say your Loader object is called loader.

I'm pretty sure you could just do:
PHP Code:
loader.unload();
loader.load(new URLRequest(yourfile));
That'll unload its current loaded content freeing up the ability to load in the new file for your loader object.
AfternoonDelite is offline   Reply With Quote
Old 07-12-2007, 08:32 AM   #5
mswallace
Matthew Wallace Web Developmen
 
Join Date: Jul 2007
Location: Spring Hill, TN
Posts: 3
most likely I will give each suggestion a try. What would be great is to be able to load the new content in place of the old content without having to do an extra step. In this case the unload and then load again, but that may be the only way you can do it.
mswallace is offline   Reply With Quote
Reply

Go Back   Flash Kit Community Forums > Flash Help > Actionscript 3.0

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 -4. The time now is 08:23 PM.


internet.commerce
Be a Commerce Partner
 »  »  »  »  »  »  »
 »  »  »  »  »  »
 

    

Acceptable Use Policy

Internet.com
The Network for Technology Professionals

Search:

About Internet.com

Legal Notices, Licensing, Permissions, Privacy Policy.
Advertise | Newsletters | E-mail Offers


Powered by vBulletin® Version 3.8.1
Copyright ©2000 - 2010, Jelsoft Enterprises Ltd.