A Flash Developer Resource Site

Results 1 to 2 of 2

Thread: duplicate movie clips for multiple MC's

  1. #1
    Senior Member
    Join Date
    Jul 2001

    duplicate movie clips for multiple MC's

    I need to duplicate several MC's (each one x 20) when he movie is loaded.

    I can't get it to work for the life of me....

    Any ideas?

    this code resides in _root.MC and the first frame
    ================================================== ==
    count = 0;

    function dup1() {
    while (count<20) {
    circle.duplicateMovieClip("circle"+count, count);

    count2 = 0;
    function dup2() {
    while (count2<20) {
    circle2.duplicateMovieClip("circle2"+count2, count2);


    ================================================== =
    Only duplicates the circle2. If I don't initiate the 2nd func (dup2();...it works for circle...and visa/versa?????????

    Can you NOT do duplicate movies for multiple MC's??

  2. #2
    Senior Member jbum's Avatar
    Join Date
    Feb 2004
    Los Angeles
    The problem is the depth of the movies you are duplicating (the 2nd parameter).

    You can only have one movieclip at a particular depth. If you try to put a second movieclip at the same depth, it obliterates the first one. To fix, in your dup2 code, change this line:

    circle2.duplicateMovieClip("circle2"+count2, count2);

    to this:

    circle2.duplicateMovieClip("circle2"+count2, count2 + 20);

    so the second set of movies go to unique depths.

    It's also worth mentioning that you could use a single function that accepts parameters, and reduce the amount of code by half.

    For example:


    function myDupe(mc, nameRoot, minDepth)
    for (count = 0; count < 20; ++count)
    mc.duplicateMovieClip(nameRoot+count, minDepth+count);

    myDupe(circle, "circle", 0);
    myDupe(circle2, "circle2", 20);

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