[MX04] Working out end of motion

Hi all

I’ve been playing with the Kirupa gravity tutorial here:

http://www.kirupa.com/developer/actionscript/gravity.htm

At the end of the motion I want to jump to a new movieclip and remove this one

I thought of placing this in the onClipEvent(EnterFrame)

   
 if (this._y == floor && speedy == 0) {
    _root.particles.gotoAndPlay(2);
 }

But no joy.

Does anyone have any suggestions for detecting the end of the bounce and jumping to the new movieclip?

Just in case I’ve messed up the original code too much, here’s what I have minus the test for motion stopping:





onClipEvent (load) {
    stop();
    gravity = 5 ;

    // We get the time when the ball is released for the
    // first time. Be careful with the division by 100
    time = getTimer () ;
    time /= 100 ;
    
    floor = 300 ;
    
    bounce = 0.5 ;
    
    // We set the speed of the ball when it is released.
    speedx = 0 ;
    speedystart = 0 ;
}

onClipEvent (enterFrame) {

    // We get the current time (still /100)
    timenow = getTimer () ;
    timenow /= 100 ;
    speedy = gravity * (timenow - time) + speedystart ;
    
    //We move the ball
    //this._x += speedx/5 ;
    this._y += speedy/5 ;
    
    if (this._y > floor) {
        this._y = floor ;
        speedy *= -bounce ;
        time = getTimer () ;
        time /= 100 ;
        // reset the timer
        speedystart = speedy ;
        // reset the starting speed
    }
}

Thanks in advance…