【问题标题】:ActionScript 3.0 - 2 gotoAndPlay() commands in one functionActionScript 3.0 - 一个函数中有 2 个 gotoAndPlay() 命令
【发布时间】:2012-07-09 01:39:58
【问题描述】:

我有以下 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);

感谢您的关注!

【问题讨论】:

    标签: function actionscript command


    【解决方案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);
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2014-05-08
      • 2011-08-15
      • 1970-01-01
      • 2010-11-15
      • 2012-04-26
      • 2011-04-08
      • 2014-09-07
      • 2014-05-23
      相关资源
      最近更新 更多