-
how to duplicate movieClip in AS3?
hi,
i have movieClip on stage with name ==>> myStar
i do not know how to duplicate that movieClip ?
i am trying
Code:
var myStarContainor:Sprite = new Sprite();
myStarContainor.addChild(myStar1);
myStarContainor.addChild(myStar2);
myStar1.x=100;
myStar2.y=100;
but i do not get any thing .. please .. how to use it correctly?
-
Senior Member
You can only create a new instance of the class.
- The right of the People to create Flash movies shall not be infringed. -
-
then how do i duplicate the movieClip "myStar" using the AS3?
-
Senior Member
You cannot duplicate any movieclip. Here is however some class, which you can use instead.
http://www.kirupa.com/forum/showthread.php?p=1939827
- The right of the People to create Flash movies shall not be infringed. -
-
go blues !
Um, and so when I want to load in images, and then duplicate them - they have to be constantly reloaded ?
-
Vox
Sorry to resurrect a dead thread, but I had the same problem as the OP and I believe I've found the answer he's looking for:
http://flash.lillegutt.com/?p=55
You have to use the clone() function on bitmapData.
-
It`s not the best solution, but it works.
var originalSprite:Sprite = new Sprite();
var copyOriginalSprite1:Sprite = new Sprite();
copyOriginalSprite1 = Sprite(DisplayObject(originalSprite));
var copyOriginalSprite2:Sprite = new Sprite();
copyOriginalSprite2 = Sprite(DisplayObject(originalSprite));
var copyOriginalSprite3:Sprite = new Sprite();
copyOriginalSprite3 = Sprite(DisplayObject(originalSprite));
-
i believe you'll have to do a loop that will create the following above mentioned by vencedor.
-
The general way to duplicate a DisplayObject that is on the stage is to create a new instance as suggested by cancerinform... e.g.
Actionscript Code:
var myDuplicate:MovieClip = new OriginalClipClass();
However, you need to explicitly give the original on-stage clip a linkage in it's properties panel in the Library for this to work.
This bit of code will dynamically get the linkage to your original clip and create a duplicate and add it to the stage... It also appears that if you use the getDefinitionByName() and getQualifiedClassName() methods... you don't need to explicitly export the MovieClip for ActionScript from the Library panel.
Actionscript Code:
var myLinkage:Class = Class(getDefinitionByName(getQualifiedClassName(myOnStageClip))); var myDuplicateClip:MovieClip = new myLinkage(); myDuplicateClip.name = "myOnStageClip" + "_Dup1"; addChild(myDuplicateClip);
-
is it working?
I tested without explicitly exporting the movielclip from library. But it didn't work. I noticed that even you export the MC with any name, it is showing the duplicate movie clip on the stage.
-
-
Originally Posted by _r2
yes of course and we all speak french
-
Originally Posted by zazuna
yes of course and we all speak french
You're on a Flash development forum, which would indicate that you have some sort of technical knowledge, and you don't know to use the Google Translate add-on in Chrome...or FireFox...or Internet Explorer...or Safari? Pretty standard really. For those who are not aware of this, I took the time (one click) to translate it for you.
Duplicate a MovieClip, a Sprite, DisplayObject one ...
After searching a few places on the Internet and see the same answer that says it is impossible to duplicate a MovieClip, a Sprite or any object that inherits from DisplayObject, I studied the issue and I found a solution more or less tangible ...
The project is called FlCloneIt you can get here: FlCloneIt.swc .
I compiled the class form. Swc that you can freely use and distribute as you cite the source (ie me and this blog: D).
Globally, it allows you to duplicate any object type .
Using a MovieClip :
Code:
var mctest: MovieClip = new MovieClip ();
var copy: * = FlCloneIt. clone ( mctest) / / Just pass it a parameter subject to duplicate
copy. name = "different_from_target"; / / If the object has a name, consider giving him another to avoid conflict
You are now in possession of an exact replica of your first movie clip!
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
|