|
-
Matthew Wallace Web Developmen
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
-
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.
-
Matthew Wallace Web Developmen
That should work
Thanks I will give that a try. That should work.
thanks,
Matthew
-
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.
-
Matthew Wallace Web Developmen
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.
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
|