Collision detection woes

Hi,
I am seriously confused, I am trying to get my head around collision detection, I had used a technique discussed at seb.ly for frame independent collision detection. I decided to test it out with a simple collision based game. Breakout! where there is a bat a ball and 3 walls I got all of that working really well, until I tried to do it for the blocks I want it to find the collisions on all 4 sides and react accordingly. I would either like a tutorial where someone explains the logic etc or if some could look at my code and point out where I am going wrong.

This is my code: all the objects are on the stage, i.e. bat, ball, leftWall, rightWall, block1, block2, block3, etc

This is my code:

package {
    import flash.display.MovieClip;

    import flash.events.KeyboardEvent;
    import flash.display.Stage;
    import flash.events.Event;
    import flash.events.*;
    import flash.display.*;
    public class Main extends MovieClip {

        public var gravity:Number = 1;
        public var restitution:Number = 0.6;
        public var friction:Number = 0.9;
        public var velX = -5;
        public var velY = 5;
        public var numberOfBlocks = 10;

        function Main() {
            init();
        }
        function init() {
            stage.addEventListener( KeyboardEvent.KEY_DOWN, keyDownHandler);
            stage.addEventListener(Event.ENTER_FRAME,gameLoop);
        }
        function keyDownHandler(kb:KeyboardEvent) {
            if ((bat.x>0)&&(bat.x<300)) {
                if (kb.keyCode==37) {

                    bat.x-=10;
                    kb.updateAfterEvent();
                }
                if (kb.keyCode==39) {
                    bat.x+=10;
                    kb.updateAfterEvent();
                }
            }
        }
        function testBlocksCollisions() {

            for (var i:int = 0; i<10; i++) {
                if (getChildByName('block'+i)!=null) {
                    var myClip:MovieClip = getChildByName('block'+i) as MovieClip;
                    var myBottom = myClip.y//-(myClip.height);
                    var myTop = myClip.y;
                    var myRight= myClip.x+myClip.width;
                    var myLeft = myClip.x;
                    var myClipX = myClip.x;
                    var myClipY = myClip.y;
                    var ballY = ball.y;
                    var ballX = ball.x;
                    var radius = ball.width/2;
                    var distanceY = myClipY-(ballY+radius);
                    var timeHitY = distanceY / velY;
                    var distanceX = myClipX-(ballX+radius);
                    var timeHitX = distanceX / velX;

                    
                    
                    if (timeHitX>=0&&timeHitX<1) {
                        trace('((ballY>myTop)&&(ballY<myBottom)): ' +((ballY>myTop)&&(ballY<myBottom-20)))
                        if ((ballY>myTop)&&(ballY<myBottom)) {
                            trace('ballX: ' + ballX);
                            trace('myLeft: ' + myLeft);
                            if ((ballX<myLeft)) {
                                trace('.............................Left.........................');
                                ballX += (velX*timeHitX);
                                removeChild(myClip);
                                velX*= -1;
                            return;
                            }
                            if ((ballX+(myRight.height)>=myRight)) {
                                trace('.............................Right.............................');
                                ballX += (velX*timeHitX);
                                velX*= -1;
                                removeChild(myClip);
                            return;
                            }
                        }
                    }
                    if ((timeHitY>=0)&&(timeHitY<=1)) {
                        trace('HITY-----------------------')
                        if (ballX>myLeft&&ballX<myRight) {
                            if ((ballY+(ball.height/2)>=myBottom)) {
                                trace('**********************************Bottom**********************************');
                                ballY += (velY*timeHitX);
                                velY*= -1;
                                removeChild(myClip);
                                return;
                            }
                        if ((ballY<=myTop)) {
                            trace('ballY: ' + ballY);
                            trace('myBottom: ' + myBottom);
                                trace('**********************************Top**********************************');
                                ballY += (velY*timeHitX);
                                velY*= -1;
                                removeChild(myClip);
                                return;
                            }
                        }
                    }
                }
            }
        }
        function gameLoop(e:Event) {
            //findNumberOfBlocks();
            moveBall();
            checkCollisionBallLeftWall();
            checkCollisionBallRightWall();
            collisionWithBat();
            checkCollisionWithTop();
            testBlocksCollisions();
        }
        function moveBall() {
            ball.x+=velX;
            ball.y+=velY;
        }
        function checkCollisionWithTop() {
            if (ball.y<4) {
                velY*=-1;
            }
        }
        function collisionWithBat() {
            var batY = bat.y;
            var ballY = ball.y;
            var radius = ball.width/2;
            var distance = batY-(ballY+radius);
            var timeHit = distance / velX;
            if ((timeHit>=0)&&(timeHit<1)) {
                ballY += (velY*timeHit);
                if ((ball.x>=bat.x)&&(ball.x<=bat.x+bat.width)) {
                    velY*= -1;
                }
            }
        }
        function checkCollisionBallRightWall() {
            var wallX = rightWall.x;
            var ballX = ball.x;
            var radius = ball.width/2;
            var distance = wallX-(ballX+radius);
            var timeHit = distance / velX;
            if ((timeHit>=0)&&(timeHit<1)) {
                ballX += (velX*timeHit);
                velX*= -1;
            }
        }
        function checkCollisionBallLeftWall() {
            var wallX = leftWall.x;
            var ballX = ball.x;
            var radius = ball.width/2;
            var distance = wallX-(ballX+radius);
            var timeHit = distance / velX;
            if ((timeHit>=0)&&(timeHit<1)) {
                ballX += (velX*timeHit);
                velX*= -1;
            }
        }
    }
}

thank you in advance