Duplicate Movieclip Flash Action Script Enhanced
Hi Guys, finally after a long time i have found some time to update the duplicate process for flash. It was prity strange why even in action script 3 there is no clone method. Any ways i have devised my own strategy for doing that.
To duplicate movieclip objects in flash as3 is realy easy. All you have to do is create a class against a movie clip and instantiate objects of that class and keep adding the objects on to Stage.
In the example attached I have created 3 display objects mcP1,mcP2 and mcP3 also i have associated these objects with 3 classes mcP1.as, mcP2.as and mcP3.as.
Now once this is done when you click on the generate button code randomly creates object of mcP1.as, mcP2.as and mcP3.as class and add them on to the stage.
This will duplicate the objects and perhaps the easiest way to duplicate objects in action script 3 and onwards. Easy !
I hope to will solve your purpose. Looking forward for your feed back. Thank you.
Working sample can be viewed on the following link.
Awaiting feed back on this. Thank you
Did you enjoy this post? Why not leave a comment below and continue the conversation, or subscribe to my feed and get articles like this delivered automatically to your feed reader.
Comments
wow,, good methods, Please update faster your blog, you tell us amazing things, I also am a beginner flasher ..
I get to use some free flash components from flash components.net
[Reply]
It keeps telling me the error
“Acces of undefined property mcMain”
While I do import all the necessary classes …
What do I do wrong?
[Reply]
Hi,
I am working on an isometric engine called IsoEngine. I need to duplicate an swf externally loaded. The problem is that after being loaded and duplicated the resulting movieClip lose all its embedded actionScript. Therefore a clip containing 2 or more frames will loop infinitely regardless the stop() that you would have put on the targeted swf file.
I am using the following function to duplicate my swf loaded:
var targetClass:Class = Object(loader.content).constructor;
var duplicate:DisplayObject = new targetClass();
Any idea of how we could duplicate an swf and keep its own actionscript?
Thanks in advance
[Reply]

Wondering if there is a relatively simple way to duplicate a movieclip that has a bitmap loaded into it at runtime.
Loading the bitmap multiple times is not an option. I have yet to find a solution that doesn’t involve manipulating bitmap data.
Silly that AS3 can’t directly address a very common use case that importing the bitmap while authoring does natively.
Thanks for sharing this class.
[Reply]