# Problem with for loop

**URL:** https://forum.kirupa.com/t/problem-with-for-loop/292377
**Category:** Uncategorized
**Created:** [July 13, 2009, 6:32pm UTC](https://forum.kirupa.com/t/problem-with-for-loop/292377 "2009-07-13T18:32:47Z")
**Posts on this page:** 1
**Page:** 1

<div class="post-metadata">

### Author: ![gencoglu](https://avatars.discourse-cdn.com/v4/letter/g/898d66/32.png) [@gencoglu](https://forum.kirupa.com/u/gencoglu)
#### Post date: [July 13, 2009, 6:32pm UTC](https://forum.kirupa.com/t/problem-with-for-loop/292377/1 "2009-07-13T18:32:47Z")

</div>

hi there,  
Following is the code I paste in the first frame of layer1…it was working before I added for loop…  
I am tring to explode all six balls on the stage clicking…but what is missing ?How can I get it work ?

for (var i = 1; i\<6; i++) {  
ball\*.onPress = function() {  
ball\*.gotoAndPlay(“explode”);  
};  
}

thanks
