hitTestPoint to change direction of moving object

I’m having a problem changing the direction of a movieclip using hitTestPoint. I have some balls on the screen that only move left, right, up and down. and pending the way they are moving they have to change direction. if they’re moving right they have to change to up. left to down, up to right and down to left. I tried the following code for getting a ball moving moving right to change to up.

note: movingDir is just a string i use to keep track of how the ball is moving and is defined initially in another class.

here is a snippet from the ball class:


this._movingDir = "right";
this._speedR = 5;
this.x += this._speedR;


public function hittingRebounder(e:Event):void {
            for(var c:uint = 0; c < Ball.ballsArray.length; c++){
                if(Ball.ballsArray[c].hitTestPoint(this.x, this.y)){
                    if(Ball.ballsArray[c]._movingDir == "right"){
                        trace("right");
                        upMoving.push(Ball.ballsArray[c]);
                        Ball.ballsArray[c].addEventListener(Event.ENTER_FRAME, greenPo****U);
                    }
                    else if(Ball.ballsArray[c]._movingDir == "left"){
                        trace("left");
                    }
                    else if(Ball.ballsArray[c]._movingDir == "up"){
                        trace("up");
                    }
                    else if(Ball.ballsArray[c]._movingDir == "down"){
                        trace("down");
                    }
                }
            }
        }

public function greenPo****U(e:Event):void {
            for(var g:uint = 0; g < upMoving.length; g++){
                
                upMoving[g]._movingDir = "up"
                upMoving[g]._speedR = 0;
                upMoving[g]._speedU = 5;
                upMoving[g].y -= upMoving[g]._speedU;
            }
            
        }

Help would be much appreciated. Thanks.