2012-07-09 79 views
1

我有以下的Adobe的Flash(ActionScript 3.0)电影:的ActionScript 3.0 - 2的gotoAndPlay()在一个函数命令

enter image description here

当按下按钮,我想打架17至24,和在此之后,我想回到第10帧到第16帧播放相同的动画。我已经试过这样的事情可惜不工作:

button.addEventListener(MouseEvent.CLICK, buttonClick); 

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

在其他总而言之一句话:gotoAndPlay(17);后,我想gotoAndPlay(10);

感谢您的关注!

回答

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);