1

我有以下 Adob​​e Flash (ActionScript 3.0) 电影:

在此处输入图像描述

当按下按钮时,我想播放第 17 帧到第 24 帧,之后,我想返回并在同一动画中播放第 10 帧到第 16 帧。我已经尝试过这样的事情,但不幸的是不起作用:

button.addEventListener(MouseEvent.CLICK, buttonClick);

function buttonClick(event:MouseEvent):void{
        gotoAndPlay(17);
        gotoAndPlay(10);
}

换句话说:gotoAndPlay(17);我要gotoAndPlay(10);

感谢您的关注!

4

1 回答 1

1

试试这个:

stop();


// Properties.
var queue:Array = [];
var currentBlock:Point;


// Queue a section of timeline to play.
function queueBlock(start:int, end:int):void
{
    queue.push(new Point(start, end));
}


addEventListener(Event.ENTER_FRAME, enterFrame);
function enterFrame(e:Event):void
{
    if(!currentBlock)
    {
        if(queue.length > 0)
        {
            // Select and remove first block to play.
            currentBlock = queue[0];
            queue.splice(0, 1);

            gotoAndPlay(currentBlock.x);
        }
    }
    else
    {
        play();

        if(currentBlock.y == currentFrame)
        {
            // Got to the end of the block, end it.
            currentBlock = null;
            stop();
        }
    }
}

这将让你这样做:

// Demo:
queueBlock(17, 24);
queueBlock(10, 16);
于 2012-07-09T02:36:45.960 回答