well say you have 2 walls: top_wall & bottom_wall. when the ball bounces off either of the walls you want the ._y direction to go the opposite way.
make a MC of a ball (any size) and change it's instance name to "ball". make 2 MCs that are thin horizontal lines calling one "top_wall" and the other "bottom_wall";
type this in actions...
ball.y = 5;
onEnterFrame = function(){
if(ball._y == top_wall._y || ball._y+ball._height == bottom_wall._y){
ball.y *= -1;
}
ball._x += 5;
ball._y += ball.y;
}
this is what will change when you hit the wall.
ball.y = 5;
anything inside of this will repeat every frame.
onEnterFrame = function(){}
this means if the ball is touching the top wall or touching the bottom wall it will make ball.y negative. (eg. 5 will be -5, -5 will be 5)
if(ball._y == top_wall._y || ball._y+ball._height == bottom_wall._y){
ball.y *= -1;
}
these make the ball move by 5. the _y of the ball will change depending on the value of ball.y
ball._x += 5;
ball._y += ball.y;