A Flash Developer Resource Site

Results 1 to 6 of 6

Thread: duplicating one mc

  1. #1
    Senior Member
    Join Date
    Nov 2000
    Posts
    168
    Hello-

    I'm a little out of practice so I came here to consult the Flash gurus. I want to take one mc and when the movie is loaded I want to duplicate that mc a random number of times (within 40 or 50) then assign each of those mc's random attributes such as alpha level and dimensions.

    I'm assuming it'll be some kind of loop to create the mc's then another loop to assign the attributes to each of the created mc's.

    I appreciated any and all help.

    Thanks
    Dan

  2. #2
    Senior Member SJT's Avatar
    Join Date
    Mar 2000
    Location
    London, UK
    Posts
    2,563
    Yeah it is a loop,

    [code]for (x=0; x<50; x++){
    duplicateMovie Clip (_level0.original, "mc"+x, x ) ;

  3. #3
    Senior Member SJT's Avatar
    Join Date
    Mar 2000
    Location
    London, UK
    Posts
    2,563

    //put the bit from the post above here.
    Code:
    alphaTemp = math.random()*100;
       xTemp = math.random()*100;
       yTemp = math.random()*100;
    //for some reason flashkit keeps breaking the code
       _root["mc"+x]._alpha = alphaTemp;
       _root["mc"+x]._xscale = xTemp;
       _root["mc"+x]._yscale = yTemp;
    }
    Hows that? I had to post in bits as vB was having real trouble not messing up the code...

    Original is the name of the starting movieclip on the stage.

  4. #4
    Senior Member
    Join Date
    Nov 2000
    Posts
    168
    Thanks for the help. I'm gonna give it a go right now.

  5. #5
    Senior Member
    Join Date
    Nov 2000
    Posts
    168
    Why does this only duplicate once? It seems to not want to loop.

    alphaTemp = math.random()*100;
    xTemp = math.random()*100;
    yTemp = math.random()*100;
    xpos = math.random()*550;
    ypos = math.random()*400;
    count = 1;

    while (count<50){
    duplicateMovieClip ("block","mc"+count, count);
    _root["mc"+count]._alpha = alphaTemp;
    _root["mc"+count]._xscale = xTemp;
    _root["mc"+count]._yscale = yTemp;
    _root["mc"+count]._x = xpos;
    _root["mc"+count]._y = ypos;
    count++;
    }


    The code is on frame 1 of the main timeline and "block" movie clip is on frame one as well. on seperate layers of course.

    Any thoughts

    Thanks
    Dan

  6. #6
    Senior Member SJT's Avatar
    Join Date
    Mar 2000
    Location
    London, UK
    Posts
    2,563
    it's not duplicating once, it's doing it 50 times, but the position and size of all the clips is exactly the same.
    You have to pu the random generators in the loop as well to get random attributes for each 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