# duplicateMovieClip - Random variables

**URL:** https://forum.kirupa.com/t/duplicatemovieclip-random-variables/265045
**Category:** flash
**Created:** [July 3, 2008, 10:19am UTC](https://forum.kirupa.com/t/duplicatemovieclip-random-variables/265045 "2008-07-03T10:19:44Z")
**Posts on this page:** 8
**Page:** 1

<div class="post-metadata">

### Author: ![gigaboost](https://avatars.discourse-cdn.com/v4/letter/g/58956e/32.png) [@gigaboost](https://forum.kirupa.com/u/gigaboost)
#### Post date: [July 3, 2008, 10:19am UTC](https://forum.kirupa.com/t/duplicatemovieclip-random-variables/265045/1 "2008-07-03T10:19:44Z")

</div>

It seems like the random variables in my duplicated movieclips are all the same, any way to change this?

To explain a bit more in detail: I got a movieclip with a few random variables and actions and I duplicate this movieclip and want the duplicate to have different random variables than the first one, but it gets identical ones.

---

<div class="post-metadata">

### Author: ![pantas](https://avatars.discourse-cdn.com/v4/letter/p/3e96dc/32.png) [@pantas](https://forum.kirupa.com/u/pantas)
#### Post date: [July 3, 2008, 10:24am UTC](https://forum.kirupa.com/t/duplicatemovieclip-random-variables/265045/2 "2008-07-03T10:24:56Z")

</div>

think about it…why is that happening?

because you duplicate it when the variables are set…

change the script so that when you duplicate the movie, you create those random vars…  
or paste the code here and well help you

---

<div class="post-metadata">

### Author: ![gigaboost](https://avatars.discourse-cdn.com/v4/letter/g/58956e/32.png) [@gigaboost](https://forum.kirupa.com/u/gigaboost)
#### Post date: [July 3, 2008, 10:38am UTC](https://forum.kirupa.com/t/duplicatemovieclip-random-variables/265045/3 "2008-07-03T10:38:10Z")

</div>

Yeah, I figured. But how do I create variables outside of onClipEvent(load) properly?

```php
onClipEvent (load) {
    //variables

    rndm = Math.random()*2;
    rndm2 = Math.random()+1*15;
    rndm3 = Math.random()*100;
}

```

---

<div class="post-metadata">

### Author: ![pantas](https://avatars.discourse-cdn.com/v4/letter/p/3e96dc/32.png) [@pantas](https://forum.kirupa.com/u/pantas)
#### Post date: [July 3, 2008, 10:44am UTC](https://forum.kirupa.com/t/duplicatemovieclip-random-variables/265045/4 "2008-07-03T10:44:32Z")

</div>

onClipEvent (load) {  
//variables

```
[COLOR="Red"]this[/COLOR].rndm = Math.random()*2;
[COLOR="Red"]this[/COLOR].rndm2 = Math.random()+1*15;
[COLOR="Red"]this[/COLOR].rndm3 = Math.random()*100;

```

}

now the vars are inside the clip 🙂

---

<div class="post-metadata">

### Author: ![gigaboost](https://avatars.discourse-cdn.com/v4/letter/g/58956e/32.png) [@gigaboost](https://forum.kirupa.com/u/gigaboost)
#### Post date: [July 3, 2008, 10:49am UTC](https://forum.kirupa.com/t/duplicatemovieclip-random-variables/265045/5 "2008-07-03T10:49:04Z")

</div>

[quote=pantas;2352982]onClipEvent (load) {  
//variables

```
[COLOR=Red]this[/COLOR].rndm = Math.random()*2;
[COLOR=Red]this[/COLOR].rndm2 = Math.random()+1*15;
[COLOR=Red]this[/COLOR].rndm3 = Math.random()*100;

```

}

now the vars are inside the clip :)[/quote]

/facepalm

Such an easy solution. Worked great, thanks.

---

<div class="post-metadata">

### Author: ![pantas](https://avatars.discourse-cdn.com/v4/letter/p/3e96dc/32.png) [@pantas](https://forum.kirupa.com/u/pantas)
#### Post date: [July 3, 2008, 10:57am UTC](https://forum.kirupa.com/t/duplicatemovieclip-random-variables/265045/6 "2008-07-03T10:57:37Z")

</div>

😉

---

<div class="post-metadata">

### Author: ![gigaboost](https://avatars.discourse-cdn.com/v4/letter/g/58956e/32.png) [@gigaboost](https://forum.kirupa.com/u/gigaboost)
#### Post date: [July 3, 2008, 11:03am UTC](https://forum.kirupa.com/t/duplicatemovieclip-random-variables/265045/7 "2008-07-03T11:03:23Z")

</div>

[http://www.imagedoll.com/show.php/10575\_particle.swf.html](http://www.imagedoll.com/show.php/10575_particle.swf.html)  
end result for anyone interested, move the mouse around, slower makes it look better.

---

<div class="post-metadata">

### Author: ![pantas](https://avatars.discourse-cdn.com/v4/letter/p/3e96dc/32.png) [@pantas](https://forum.kirupa.com/u/pantas)
#### Post date: [July 3, 2008, 11:49am UTC](https://forum.kirupa.com/t/duplicatemovieclip-random-variables/265045/8 "2008-07-03T11:49:15Z")

</div>

nice!
