# Duplicate mc Script problems

**URL:** <https://forum.kirupa.com/t/duplicate-mc-script-problems/35027>\
**Category:** Uncategorized\
**Created:** [November 9, 2003, 3:06pm UTC](https://forum.kirupa.com/t/duplicate-mc-script-problems/35027 "2003-11-09T15:06:49Z")\
**Posts on this page:** 13\
**Page:** 1

<div class="post-metadata">

**Author:** ![Fargate](https://avatars.discourse-cdn.com/v4/letter/f/dbc845/32.png) [@Fargate](https://forum.kirupa.com/u/Fargate)\
**Post date:** [November 9, 2003, 3:06pm UTC](https://forum.kirupa.com/t/duplicate-mc-script-problems/35027/1 "2003-11-09T15:06:49Z")

</div>

Ok… I tried to put the following script into my mc…

[AS]onClipEvent (load) {  
amount = 10;  
while (amount\>0) {  
duplicateMovieClip(\_root.flower, “mc”+i, i);  
setProperty(“mc”+i, \_x, random(275));  
setProperty(“mc”+i, \_y, random(275));  
setProperty(“mc”+i, \_alpha, random(275));  
setProperty(“mc”+i, \_xscale, random(50));  
setProperty(“mc”+i, \_yscale, random(50));  
i++;  
amount–;  
}  
}  
[/AS]

When I try to run it gives me this message:

```
  A script in this movie is causing flash player to run slowly. If it continues to run, your computer may become unresponsive.Do you want to abort the script?

```

* * *

… Is it something in my script how could I fix this?? I’ve attached the file.

---

<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:** [November 9, 2003, 3:30pm UTC](https://forum.kirupa.com/t/duplicate-mc-script-problems/35027/2 "2003-11-09T15:30:21Z")

</div>

is it ON flower? if so, when duplicating it, that script will remain and be run on all duplicates thereby creating an infinite loop.

on a side note, i is never changed in that script which mean the duplicate will only be made once… well more than once but since i stays the same each new duplicate will replace the prior

---

<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:** [November 9, 2003, 3:42pm UTC](https://forum.kirupa.com/t/duplicate-mc-script-problems/35027/3 "2003-11-09T15:42:15Z")

</div>

Ok it’s on that mc…but you totally lost me…I still don’t understand what I’m supposed to change…

---

<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:** [November 9, 2003, 3:51pm UTC](https://forum.kirupa.com/t/duplicate-mc-script-problems/35027/4 "2003-11-09T15:51:49Z")

</div>

You can’t place it on the image itself, because when it’s duplicated, it will have the same code on it I think and therefore every duplicated movieclip will dyuplicate itself again 10 times. And each of those will duplicate themselves too. And so on. So I suggest you code in the timeline.

---

<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:** [November 9, 2003, 4:09pm UTC](https://forum.kirupa.com/t/duplicate-mc-script-problems/35027/5 "2003-11-09T16:09:53Z")

</div>

Well I put my current code in the main timeline and that doesn’t do anything…could you give me and example of what your talking about?

This is the current script I have in the timeline…(I changed the instance names…)

[AS]  
amount = 10;  
while (amount\>0) {  
duplicateMovieClip(\_root.target\_mc, “target\_mc”+i, i);  
setProperty(“mc”+i, \_x, random(275));  
setProperty(“mc”+i, \_y, random(275));  
setProperty(“mc”+i, \_alpha, random(275));  
setProperty(“mc”+i, \_xscale, random(50));  
setProperty(“mc”+i, \_yscale, random(50));  
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:** [November 9, 2003, 4:15pm UTC](https://forum.kirupa.com/t/duplicate-mc-script-problems/35027/6 "2003-11-09T16:15:14Z")

</div>

On the timeline in which flower is in …

```auto

amount = 10;
for(var i=0;i<=amount;i++){
                mc = flower.duplicateMovieClip("mc"+i, i);
                mc._x = Math.floor(Math.random()*(275+1))
                mc._y = Math.floor(Math.random()*(275+1))
                mc._alpha = Math.floor(Math.random()*(275+1))
                mc._xscale = Math.floor(Math.random()*(50+1))
                mc._yscale = Math.floor(Math.random()*(50+1))
// Good like this, sen ? ;-)
}

```

That should do it 🙂

---

<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:** [November 9, 2003, 4:22pm UTC](https://forum.kirupa.com/t/duplicate-mc-script-problems/35027/7 "2003-11-09T16:22:26Z")

</div>

whoa…wierd…I stick that in…and well look at the attached screen shot…very wierd…I really don’t understand…

Everything looks warped…or something…I’m guess it has something to do with the MathRandom…

---

<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:** [November 9, 2003, 7:24pm UTC](https://forum.kirupa.com/t/duplicate-mc-script-problems/35027/8 "2003-11-09T19:24:35Z")

</div>

yeah. Well it IS random 😉

---

<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:** [November 9, 2003, 8:58pm UTC](https://forum.kirupa.com/t/duplicate-mc-script-problems/35027/9 "2003-11-09T20:58:42Z")

</div>

Ok but what would I do just to have non-skewed targets of different sizes duplicating at different locations and depths?

---

<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:** [November 11, 2003, 1:25am UTC](https://forum.kirupa.com/t/duplicate-mc-script-problems/35027/10 "2003-11-11T01:25:03Z")

</div>

hello??

---

<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:** [November 11, 2003, 1:31am UTC](https://forum.kirupa.com/t/duplicate-mc-script-problems/35027/11 "2003-11-11T01:31:01Z")

</div>

```auto
amount = 10;
for (var i = 0; i<=amount; i++) {
	mc = flower.duplicateMovieClip("mc"+i, i);
	mc._x = Math.floor(Math.random()*(275+1));
	mc._y = Math.floor(Math.random()*(275+1));
	mc._alpha = Math.floor(Math.random()*(275+1));
	mc._xscale = mc._yscale=Math.floor(Math.random()*(50+1));
}

```

---

<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:** [November 11, 2003, 2:49am UTC](https://forum.kirupa.com/t/duplicate-mc-script-problems/35027/12 "2003-11-11T02:49:12Z")

</div>

thanks claudio…that one seems to work the best so far… 🙂

---

<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:** [November 11, 2003, 4:34pm UTC](https://forum.kirupa.com/t/duplicate-mc-script-problems/35027/13 "2003-11-11T16:34:46Z")

</div>

welcome 🙂
