2016-06-14 23 views
0

跳回的幀現在我正在構建一個體育比賽的模擬,以2個線性半部進行,分爲2個獨立的場景。進球得分的進球作爲得分發生在舞臺上的按鈕顯示。該按鈕用作重播目標的參考。我們可以說上半場(場景1)應該可以在下半場(場景2)進行重放。 我爲每個目標創建了額外的場景,作爲單獨的回放來引用。AS3:如何跳轉到另一個場景(或幀序列)並返回到從

我想什麼讓用戶能夠,就是點擊重放按鈕在任何選定時間,觀看重播,然後回到它最初來自跳上確切的框架,併發揮對從那裏首選。

我'不能'使用movieClipsaddChild方法的原因是我希望最終的SWF保持其透明背景,因爲稍後我會將其嵌入到html中。

如果(如何?)我用的是addChild方法,你看到對方的前2部分透明movieClips,在同一時間運行。

如果我想知道如何替換另一個,這可能是適合的方法。

另一個將使用currentFrame和/或currentLabel方法我猜,但我不知道如何。

我有項目.fla file給你一個更清晰的事情。

回答

1

我們假設您有一個重播按鈕,其實例名稱爲replayBtn。下面是此設置的一種方法:

在時間軸上的第一幀,創建以下VAR和功能:

//define a variable to hold the last replay frame 
var lastReplayFrame:int = 0; 

//define a variable to hold the frame to go back to once a replay is done 
var replayReturnFrame:int = 0; 

//create a function to call after a replay is done 
function replayReturn(){ 
    //if we've set a frame to jump back to 
    if(replayReturnFrame > 0){ 
     //go there and resume playing 
     this.gotoAndPlay(replayReturnFrame); 

     //reset the return frame so we don't go back there the next time if the button isn't hit 
     replayReturnFrame = 0; 
    } 
} 

//create the click handler for the replay button: 
function replayClick(e:Event):void { 
    //check if there is a replay available 
    if(lastReplayFrame > 0){ 
     //store the current frame before jumping back 
     replayReturnFrame = this.currentFrame; 

     gotoAndPlay(lastReplayFrame); 
    } 
} 

//add the click event listener to the replay button instance 
replayBtn.addEventListener(MouseEvent.CLICK, replayClick); 

現在,在你的時間表,當一個目標開始(例如哪裏重播應該開始)的第一幀,把下面的代碼放在一個關鍵幀:

lastReplayFrame = this.currentFrame; 

然後,重播的最後一幀,把這段代碼在一個關鍵幀:

replayReturn(); 
+0

這就是我正在尋找的,謝謝! – too1s

相關問題