Need help with "for" statement

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:


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:


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.