# Ball is not bouncing off the wall?

**URL:** <https://forum.kirupa.com/t/ball-is-not-bouncing-off-the-wall/144265>\
**Category:** Uncategorized\
**Created:** [April 12, 2005, 11:03pm UTC](https://forum.kirupa.com/t/ball-is-not-bouncing-off-the-wall/144265 "2005-04-12T23:03:54Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![Crash1hd](https://avatars.discourse-cdn.com/v4/letter/c/d26b3c/32.png) [@Crash1hd](https://forum.kirupa.com/u/Crash1hd)\
**Post date:** [April 12, 2005, 11:03pm UTC](https://forum.kirupa.com/t/ball-is-not-bouncing-off-the-wall/144265/1 "2005-04-12T23:03:54Z")

</div>

below is the code I am useing I have created a simple frame with 2 layers one named body and one named Code in the code frame I have

// how fast should the ball move?  
ballYspeed = 5;  
ballXspeed = 5;

onEnterFrame = function () {  
// set the speed and position of the ball  
ball.\_y += ballYspeed;  
ball.\_x += ballXspeed;  
// if the ball hits the top or bottom  
// reverse its Y speed and position  
if (ball.hittest(bottom) || ball.hittest(top)) {  
ballYspeed \*= -1;  
}  
// if the ball hits the left or right  
// reverse its X speed and position  
if (ball.hittest(left) || ball.hittest(right)) {  
ballXspeed \*= -1;  
}  
};

In the body I have 4 walls all named top bottom right and left they are movies and they are named in there instance the same I have a circle I named ball and made it into a movie and named it ball yet when I run the flash file the ball flys off the page and doesnt bounce inside the boxes? Im confused
