# Wave

**URL:** <https://forum.kirupa.com/t/wave/180226>\
**Category:** flash\
**Created:** [February 27, 2006, 2:39am UTC](https://forum.kirupa.com/t/wave/180226 "2006-02-27T02:39:46Z")\
**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:** [February 27, 2006, 2:39am UTC](https://forum.kirupa.com/t/wave/180226/1 "2006-02-27T02:39:46Z")

</div>

I’m having a really hard learning experience. I’m trying to make a ball do a random “wave” across the stage like that one kirupa banner does.  
This is the code I have so far.

```auto
onClipEvent (load){
    width = 720;
    height = 200;
    this._x = -20;
    this._y = Math.round(Math.random()*height);
    origy = this._y
    speed = Math.round(1+Math.random()*11);
    up = true;
    faster = Math.round(1+Math.random()*6);
    slower = Math.round(5+Math.random()*6);
}
onClipEvent (enterFrame){
    this._x+=speed;
    if (speed<=5){
        yend = origy+slower;
        yup = slower;
    }
    if (speed>=6){
        yend = origy+faster;
        yup = faster;
    }
        if (this._y>yend+2){
        up=false;
    }
    if (this._y<origy+2){
        up=true;
    }
    if (up=true){
        this._y+=yup/2
    }
    if (up=false){
        this._y+=-yup/2
    }
}

```

Right now it’ll choose a random y position and angle down at a speed depending on the speed var.  
But I can’t get it to start going the other direction when it hits a certain point or over.  
Thanx.  
;(
