# Stage boarder

**URL:** <https://forum.kirupa.com/t/stage-boarder/281792>\
**Category:** Uncategorized\
**Created:** [February 13, 2009, 8:03am UTC](https://forum.kirupa.com/t/stage-boarder/281792 "2009-02-13T08:03:30Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![smallDot](https://avatars.discourse-cdn.com/v4/letter/s/a8b319/32.png) [@smallDot](https://forum.kirupa.com/u/smallDot)\
**Post date:** [February 13, 2009, 8:03am UTC](https://forum.kirupa.com/t/stage-boarder/281792/1 "2009-02-13T08:03:30Z")

</div>

i tried to modify this code so:  
1- the boarder of the ball hit exactly the the boarder of stage  
2- when the ball hit any boarder of stage it go in reverse way in different directions

```auto

stage.frameRate = 30;
ball_mc.addEventListener(Event.ENTER_FRAME, moveBall);
function moveBall(event:Event):void {
    if (ball_mc.x < stage.stageWidth - ball_mc.width + 40&& ball_mc.y < stage.stageHeight - ball_mc.height + 30) {
        ball_mc.x += 10;
        ball_mc.y += 10;
    } else if (ball_mc.x == stage.stageWidth && ball_mc.y == stage.stageHeight) {
        ball_mc.x -= 10;
        ball_mc.y -= 10;
    } else {
        ball_mc.removeEventListener(Event.ENTER_FRAME, moveBall);
    }
}

```
