Need to remove a sprite object when another sprite object hits it

Hello All,

I have a brick class where I have created a rectangle using flash.display.graphics.
I am using this brick class to create a grid of 10 X 10 in another class called grid using new brick() in a for loop.
I have another class called ball where I have created a circle with flash.display.graphics.

The problem is that I want to remove / destroy individual bricks when the ball hits the bricks on Event.ENTER_FRAME which is not happening.

the error I get is shown only for the last brick that is created in a for loop.

ArgumentError: Error #2025: The supplied DisplayObject must be a child of the caller.
at flash.display::DisplayObjectContainer/removeChild()
at grid/ball_movement()// my function in enter frame event

The code I wrote in ENTER_FRAME is

if (Ball.hitTestObject(bricks)) {
removeChild(bricks);
}

where
var Ball:ball=new ball()
var bricks:brick=new brick()

any help is highly appreciated.
thanks
iceheros :slight_smile: