PHP User Warning: fetch_template() calls should be replaced by the vB_Template class. Template name: bbcode_highlight in ..../includes/functions.php on line 4197

PHP User Warning: fetch_template() calls should be replaced by the vB_Template class. Template name: bbcode_highlight in ..../includes/functions.php on line 4197
how to duplicate movieClip in AS3?
A Flash Developer Resource Site

Results 1 to 13 of 13

Thread: how to duplicate movieClip in AS3?

  1. #1
    Junior Member
    Join Date
    Jun 2004
    Location
    Kwait
    Posts
    21

    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?

  2. #2
    Mod cancerinform's Avatar
    Join Date
    Mar 2002
    Location
    press the picture...
    Posts
    13,448
    You can only create a new instance of the class.
    - The right of the People to create Flash movies shall not be infringed. -
    | www.Flashscript.biz | Flashscript Biz Classes/Components |

  3. #3
    Junior Member
    Join Date
    Jun 2004
    Location
    Kwait
    Posts
    21
    then how do i duplicate the movieClip "myStar" using the AS3?

  4. #4
    Mod cancerinform's Avatar
    Join Date
    Mar 2002
    Location
    press the picture...
    Posts
    13,448
    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. -
    | www.Flashscript.biz | Flashscript Biz Classes/Components |

  5. #5
    go blues ! audas's Avatar
    Join Date
    Oct 2000
    Location
    london ,piccadily circus!
    Posts
    665
    Um, and so when I want to load in images, and then duplicate them - they have to be constantly reloaded ?
    peace.

  6. #6
    Vox adityadennis's Avatar
    Join Date
    Apr 2001
    Posts
    751
    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.

  7. #7
    Junior Member
    Join Date
    Apr 2009
    Posts
    1
    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));

  8. #8
    Junior Member
    Join Date
    Apr 2010
    Posts
    1
    i believe you'll have to do a loop that will create the following above mentioned by vencedor.

  9. #9
    Senior Member
    Join Date
    Jan 2006
    Posts
    133
    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);

  10. #10
    Registered User
    Join Date
    Mar 2011
    Posts
    2

    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.

  11. #11

  12. #12
    Member
    Join Date
    Apr 2006
    Posts
    32
    Quote Originally Posted by _r2 View Post
    yes of course and we all speak french

  13. #13
    Member
    Join Date
    Jun 2004
    Location
    Ypsilanti, MI
    Posts
    37
    Quote Originally Posted by zazuna View Post
    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
  •  




Click Here to Expand Forum to Full Width

HTML5 Development Center