# Duplicate Movie Clip

**URL:** https://forum.kirupa.com/t/duplicate-movie-clip/24001
**Category:** flash
**Created:** [June 25, 2003, 5:40am UTC](https://forum.kirupa.com/t/duplicate-movie-clip/24001 "2003-06-25T05:40:05Z")
**Posts on this page:** 12
**Page:** 1

<div class="post-metadata">

### Author: ![wyclef](https://avatars.discourse-cdn.com/v4/letter/w/65b543/32.png) [@wyclef](https://forum.kirupa.com/u/wyclef)
#### Post date: [June 25, 2003, 5:40am UTC](https://forum.kirupa.com/t/duplicate-movie-clip/24001/1 "2003-06-25T05:40:05Z")

</div>

Hi, how can I adjust the \_x and \_y area positioning of this set of duplicate movieclips? 710 x 143 are the dimensions I would like the duplicateMovieClip to take place, but it is not the positioning. How can I fix this?

[AS]  
duplicateMovieClip (flower, “mc”+i, i);  
setProperty (“mc”+i, \_x, random(710));  
setProperty (“mc”+i, \_y, random(143));  
setProperty (“mc”+i, \_alpha, random(275));  
setProperty (“mc”+i, \_xscale, random(100));  
setProperty (“mc”+i, \_yscale, random(100));  
i++;  
amount–;[/AS]

---

<div class="post-metadata">

### Author: ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)
#### Post date: [June 25, 2003, 5:48am UTC](https://forum.kirupa.com/t/duplicate-movie-clip/24001/2 "2003-06-25T05:48:09Z")

</div>

what exactly do you mean wyclef? If you mean that the \_x and \_y of the duplicated mcs is not getting randomised, i suggest u try this code instead of all those setProperty()s.  
This goes in the object actions of the mc.

onClipEvent(load){  
for(i=0;i\<50;i++){  
this.duplicateMovieClip(“flower” + i,i)

\_root[“flower” +i].\_x=Math.round(Math.random()\*710)

\_root[“flower” +i].\_y=Math.round(Math.random()\*143)

\_root[“flower” +i].\_alpha=Math.round(Math.random()\*100)

\_root[“flower” +i].\_xscale=Math.round(Math.random()\*100)

\_root[“flower” +i].\_yscale=Math.round(Math.random()\*100)  
}  
}

It should work, btw are you running mx or v5??

---

<div class="post-metadata">

### Author: ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)
#### Post date: [June 25, 2003, 7:41am UTC](https://forum.kirupa.com/t/duplicate-movie-clip/24001/3 "2003-06-25T07:41:19Z")

</div>

you could also use the initObject parameter…

```auto
var obj = {_x:random(710), _y:random(143), _alpha:random(275), _xscale:random(100), _yscale:random(100)};
flower.duplicateMovieClip("mc"+i, i, obj);

```

---

<div class="post-metadata">

### Author: ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)
#### Post date: [June 25, 2003, 9:25am UTC](https://forum.kirupa.com/t/duplicate-movie-clip/24001/4 "2003-06-25T09:25:40Z")

</div>

and kax, why is the alpha taken to be 275?? as in random(275). Is’nt the maximum alpha 100???

---

<div class="post-metadata">

### Author: ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)
#### Post date: [June 25, 2003, 9:31am UTC](https://forum.kirupa.com/t/duplicate-movie-clip/24001/5 "2003-06-25T09:31:23Z")

</div>

😛

i just copied the script from wyclef’s post and edited it, i didn’t pay attention to the properties/values. that’s why.

---

<div class="post-metadata">

### Author: ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)
#### Post date: [June 25, 2003, 2:40pm UTC](https://forum.kirupa.com/t/duplicate-movie-clip/24001/6 "2003-06-25T14:40:24Z")

</div>

I’m on Flash MX. IT seems as though the initObject might be more appropriate for Flash MX? Is this true? I’ll have to give it a shot… but this still doesn’t address the main issue which is thta I want to control the positioning of the whole mass of the randomized MCs. Right no the \_x and \_y value sets the surface area from starting from \_x:0 and \_y:0. But what if I want to start it from \_y:300?

---

<div class="post-metadata">

### Author: ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)
#### Post date: [June 25, 2003, 3:10pm UTC](https://forum.kirupa.com/t/duplicate-movie-clip/24001/7 "2003-06-25T15:10:21Z")

</div>

then use

\_root[“flower” +i].\_y=Math.round(Math.random()\*143) +300

???

---

<div class="post-metadata">

### Author: ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)
#### Post date: [June 25, 2003, 7:34pm UTC](https://forum.kirupa.com/t/duplicate-movie-clip/24001/8 "2003-06-25T19:34:32Z")

</div>

Thanks kartik, that solved my problem. But now i’m curious about this initObject thing. I tried copying and pasting kaxs two lines but it didn’t work. What am I doing wrong and why is this a better method than set property?

---

<div class="post-metadata">

### Author: ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)
#### Post date: [June 26, 2003, 2:16am UTC](https://forum.kirupa.com/t/duplicate-movie-clip/24001/9 "2003-06-26T02:16:28Z")

</div>

the initObject is faster than assigning each property individually.

and the code works, but you still need to put the script within a loop. example:

```auto
var i, total = 100;
for (i=0; i<total; i++) {
var obj = {_x:random(710), _y:random(143), _alpha:random(100), _xscale:random(100), _yscale:random(100)};
flower.duplicateMovieClip("mc"+i, i, obj);
}

```

---

<div class="post-metadata">

### Author: ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)
#### Post date: [June 26, 2003, 5:24am UTC](https://forum.kirupa.com/t/duplicate-movie-clip/24001/10 "2003-06-26T05:24:28Z")

</div>

This script duplicates the MC and then randomizes them all in unison where the set property version does it randomly…you should test both versions and see,it’s cool… but how can I get the initObject version to react more like the original set property one…??? Thanks for your help

---

<div class="post-metadata">

### Author: ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)
#### Post date: [June 26, 2003, 5:35am UTC](https://forum.kirupa.com/t/duplicate-movie-clip/24001/11 "2003-06-26T05:35:49Z")

</div>

both codes work the same…

there’s only one difference between the code you posted and the code i posted, mine is about 50% faster than yours. i’m done here.

good luck.

---

<div class="post-metadata">

### Author: ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)
#### Post date: [June 26, 2003, 1:49pm UTC](https://forum.kirupa.com/t/duplicate-movie-clip/24001/12 "2003-06-26T13:49:24Z")

</div>

Did you try both codes? They don’t work the same. The original duplicates the MC randomly at different times where the initObject one duplicates the MC in unison.
