Yep, more hitTest/shapeFlag problems

Hi.
I know there are already a lot of these kinds of threads, but I did conduct a search before writing this, though I probably missed something. I’m posting this here anyway, so that I can have this problem in particular addressed, so I hope you don’t mind.

So…

I’m trying to create a Flash game engine with a wall that the character bounces off, that has so far come out like this.

Or, in image form, this:

The script on the ball is:

onClipEvent(load){
    speed = 1.75
    xspeed = 0
    yspeed = 0
    slow = .875
}
onClipEvent(enterFrame){
    if(Key.isDown(Key.LEFT)){
        xspeed -= speed
    }
    if(Key.isDown(Key.RIGHT)){
        xspeed += speed
    }
    if(Key.isDown(Key.UP)){
        yspeed -= speed
    }
    if(Key.isDown(Key.DOWN)){
        yspeed += speed
    }
    if(_root.sidewalls.hitTest(_x, _y, true)){
        xspeed *= -1
    }
    if(_root.updownwalls.hitTest(_x, _y, true)){
        yspeed *= -1
    }
    xspeed *= slow
    yspeed *= slow
    _x += xspeed
    _y += yspeed
}

And the wall instances were these:


First of all, because I’m using a shapeFlag function instead of a hitTest, because I intend to create games with sloping landscapes, the ball sinks halfway through the wall before hitting it, and I don’t know how to create more collision points in the wall.

My main problem however, is that, as you may have noticed, you can sometimes sink further than halfway through the wall, and eventually get onto the other side of it. If I could get it to keep testing the collision wherever the ball was touching the wall, I could make the wall into a kind of one-way thing, where it forces you back into the square, except I don’t know how to do that, either.

So could you help me? Or if you think that this question has already been asked, could you post a link to that thread?

Thanks. :}