# Eased random motion

**URL:** <https://forum.kirupa.com/t/eased-random-motion/180508>\
**Category:** flash\
**Created:** [March 1, 2006, 5:36am UTC](https://forum.kirupa.com/t/eased-random-motion/180508 "2006-03-01T05:36:48Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![Catalist](https://yyz1.discourse-cdn.com/flex011/user_avatar/forum.kirupa.com/catalist/32/2148_2.png) [@Catalist](https://forum.kirupa.com/u/Catalist)\
**Post date:** [March 1, 2006, 5:36am UTC](https://forum.kirupa.com/t/eased-random-motion/180508/1 "2006-03-01T05:36:48Z")

</div>

This is what I have so far. If moves the ball to the new point but doesn’t make it go to the next.

```auto
onClipEvent (load){
    width=720;
    height=480;
    this._x=Math.round(Math.random()*width);
    this._x=Math.round(Math.random()*height);
    newx=Math.round(1+Math.random()*width);
    newy=Math.round(1+Math.random()*height);
}
onClipEvent (enterFrame){
    speedx=Math.abs(newx-this._x);
    speedy=Math.abs(newy-this._y);
    if (this._x<newx){
        signx=speedx;
    }else{
        signx=-speedx;
    }
    if (this._y<newy){
        signy=speedx;
    }else{
        signy-speedy;
    }
    if (speedx<newy+1){
        this._x+=signx/2;
    }else{
        newx=Math.round(1+Math.random()*width);
    }
    if (speedy<newy+1){
        this._y+=signy/2;
    }else{
        newy=Math.round(1+Math.random()*height);
    }
}

```

What’s wrong, as far as I can tell it should work fine…:bounce:
