vendredi 25 décembre 2015

How do I stop function on as3

Well... I try to stop animation that coded on as3, but can't do it. Here the code!

//this make the ground move
function GroundAndEndingMove(event:Event):void
{   
    ground.x = ground.x - 5;
    if (ground.x <= -846.24)
    {
        ground.x = -846.25;
        ending.x = 503.5;
        stop();

    }
    stopmation.x = stopmation.x - 5;
    if (stopmation.x <= -846.24)    
    {
        ground.x = -846.25;
        ending.x = 503.5;
        stop();
    }
    ending.x = ending.x - 5.1;
    if (ending.x <= 503.5)

    {
        rowl.x = 548.1;
        ending.x = 503.5;
        stop();
    }
    trash.x = trash.x - 5.1;
    if (trash.x <= 503.5)
    {   
        trash.x = 503.5;
        ball.x = ball.x + 5.1;
        stop();
    }

}
stage.addEventListener(Event.ENTER_FRAME, GroundAndEndingMove);

//this function make the ball to faled

function GameOver(event:Event):void
{
    if(ball.hitTestObject(ground))
    {
        //here I should stop the animation wherever it be.
    }
    if (ball.hitTestObject(stopmation))
    {
        //also here
    }

}
stage.addEventListener(Event.ENTER_FRAME, GameOver);

What to do? or that you have any better idea.. Help!

(Sorry about any spelling mistake... I made it long ago and I back to it right now..)

Aucun commentaire:

Enregistrer un commentaire