# Need help with "for" statement

**URL:** <https://forum.kirupa.com/t/need-help-with-for-statement/182334>\
**Category:** Uncategorized\
**Created:** [March 17, 2006, 6:41am UTC](https://forum.kirupa.com/t/need-help-with-for-statement/182334 "2006-03-17T06:41:34Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![nakor](https://avatars.discourse-cdn.com/v4/letter/n/d07c76/32.png) [@nakor](https://forum.kirupa.com/u/nakor)\
**Post date:** [March 17, 2006, 6:41am UTC](https://forum.kirupa.com/t/need-help-with-for-statement/182334/1 "2006-03-17T06:41:34Z")

</div>

HI,

I’m making a game in which you have to hit a series of blocks wih a ball. Each time you hit a block, I need it to disappear. I have been using an enterframe function that uses a for statment to try and achieve this. It looks something like this:

```auto

ball.onEnterFrame = function(){
        for(i=1;i<blocknumber;i++){
               if(_this.hitTest(_root.block + i)){
                      block+i.removeMovieClip()
               }
        }
}

```

This doesnt work. I know why it doesnt work as well, thats not the problem.

I was wondering if something like this will fix it:

```auto

ball.onEnterFrame = function(){
        for(i=1;i<blocknumber;i++){
               somevariable = "block"+i
               if(this.hitTest(somevariable)){
                      somevariable.removeMovieClip()
               }
        }
}

```

If anyone could help it would be much appreciated.
