# Building new Variables

**URL:** <https://forum.kirupa.com/t/building-new-variables/20138>\
**Category:** flash\
**Created:** [May 5, 2003, 7:54pm UTC](https://forum.kirupa.com/t/building-new-variables/20138 "2003-05-05T19:54:20Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![neutron](https://avatars.discourse-cdn.com/v4/letter/n/f08c70/32.png) [@neutron](https://forum.kirupa.com/u/neutron)\
**Post date:** [May 5, 2003, 7:54pm UTC](https://forum.kirupa.com/t/building-new-variables/20138/1 "2003-05-05T19:54:20Z")

</div>

How can i create new variables when i duplicate clips ?  
This is my code (symplified):  
For(i=o;i\<5;i++){  
\_root.createEmptyMovieClip([“clip”+i], 0);  
\_root.[“clip”+i].\_y = 25\*i;  
}

the problem is that i wan’t to be able to use Clip1 then Clip2, Clip3, etc… as my variables but i don’t know how i’m supposed to write it.  
I there is a problem with the [“Clip”+i].  
Does anyone know ?

---

<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:** [May 5, 2003, 8:39pm UTC](https://forum.kirupa.com/t/building-new-variables/20138/2 "2003-05-05T20:39:14Z")

</div>

for(i=0;i\<5;i++){  
\_root.createEmptyMovieClip(“clip”+i, i);  
\_root[“clip”+i].\_y = 25\*i;  
}

1. for is case sensitive
2. dont you mean 0 instead of o?
3. createEmptyMovieClip takes a string as an argument for the name, no [] needed
4. use i in the depth argument so they dont replace each other
5. in using [] for reference its object[stringname].property - no dot between the object and the []

for future referencing of the clips, you can use \_root.clip0 -\> \_root.clip4 or something like \_root[“clip”+0] or some variable to replace 0 which is between 0 and 4.

that 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:** [May 7, 2003, 1:51pm UTC](https://forum.kirupa.com/t/building-new-variables/20138/3 "2003-05-07T13:51:36Z")

</div>

Thanks alot senocular, i works out perfect thanks to you !

---

<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:** [May 7, 2003, 2:04pm UTC](https://forum.kirupa.com/t/building-new-variables/20138/4 "2003-05-07T14:04:01Z")

</div>

One more thing,  
when i load a movie in each newClip, i want to send a variable to that specific movie so the texte changes.  
Here’s the script :

for(i=0;i\<5;i++){  
\_root.createEmptyMovieClip(“clip”+i, i);  
\_root[“clip”+i].\_y = 25\*i;  
loadMovie(“texteDyn.swf”,“clip”+i);  
bling = “bye” + i;  
}

in the movie texteDyn.swf there’s a text variable called Bling but my command doesnt change this texte. How can i send a variable to that clip ?

---

<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:** [May 7, 2003, 2:08pm UTC](https://forum.kirupa.com/t/building-new-variables/20138/5 "2003-05-07T14:08:56Z")

</div>

\_root[“clip”+i].bling = “bye”+i;

and you’ll need to wait until the external .swf is fully loaded into the MovieClip to assign the variable, otherwise the variable will be lost once it’s fully loaded. 😉

---

<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:** [May 7, 2003, 10:14pm UTC](https://forum.kirupa.com/t/building-new-variables/20138/6 "2003-05-07T22:14:29Z")

</div>

thx alot guys your help is precious !
