# Porblems giving multipile movies actions with for loop

**URL:** <https://forum.kirupa.com/t/porblems-giving-multipile-movies-actions-with-for-loop/240378>\
**Category:** flash\
**Created:** [October 2, 2007, 2:34pm UTC](https://forum.kirupa.com/t/porblems-giving-multipile-movies-actions-with-for-loop/240378 "2007-10-02T14:34:19Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![SolBrad](https://avatars.discourse-cdn.com/v4/letter/s/e19b73/32.png) [@SolBrad](https://forum.kirupa.com/u/SolBrad)\
**Post date:** [October 2, 2007, 2:34pm UTC](https://forum.kirupa.com/t/porblems-giving-multipile-movies-actions-with-for-loop/240378/1 "2007-10-02T14:34:19Z")

</div>

Hi all happy flash coder people

I am really hoping someone can help me with this

What i want to do is assign actions to each individual movieclip using a for loop… let me explain

Say i have 5 MovieClips on the stage… With instance names clip1, clip2, clip3…

Now what i want to do is assign a OnRollOver and OnRelease to each 1  
So individual code for each would be something like this.

\_root.Clip1.OnRollOver = function()  
{  
\_root.Clip1.gotoAndPlay(2);  
trace(“clip1 clicked”)  
}  
\_root.Clip2.OnRollOver = function()  
{  
\_root.Clip2.gotoAndPlay(2);  
trace(“clip2 clicked”)  
}

now instead of copy pasting this over and over again for however many clips i have i wanted to put it in a for loop like so

for(i=1; i\<6; i++)  
{  
\_root[“Clip” + i].OnRollOver = function()  
{  
\_root[“Clip” + i].gotoAndPlay(2);  
trace(“Clip” + i + “clicked”)  
}  
}

the problem is this does not work… and all the trace statements just say clip4 clicked

how do i solve this problem, what am i doing wrong?

Please if anyone can help i would appreciate it so much

Thanks  
Brad
