Actionscript 3 如何停止as3上的功能

Actionscript 3 如何停止as3上的功能,actionscript-3,flash,Actionscript 3,Flash,嗯。。。我试图停止在as3上编码的动画,但做不到。这是密码 //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();

嗯。。。我试图停止在as3上编码的动画,但做不到。这是密码

//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);
//这会使地面移动
函数GroundAndEndingMove(事件:事件):void
{   
接地x=接地x-5;

if(ground.x我不知道它是否对您有帮助,但无论如何..尝试从stage
stage中删除事件侦听器。removeEventListener(event.ENTER_FRAME,GameOver);

这是一个简单的逻辑-您就快到了

首先考虑伪代码,不要陷入“编程”中


    if (A is true OR B is true) then
    // end game: do cleanup etc.
    // off user some option (new game, etc)
    end if
function GameOver(event:Event):void
{
    if(ball.hitTestObject(ground) || ball.hitTestObject(stopmation))
    {
     stage.removeEventListener(Event.ENTER_FRAME, GroundAndEndingMove);
     stage.removeEventListener(Event.ENTER_FRAME, GameOver);

     // all cleaned up: what happens now?
    }
}