2012-08-16 39 views
0

我有一個問題...我試圖做我的朋友閃光項目大學..它實際上很容易的東西,但我基本上沒有AS3的知識,因爲我停止使用閃光燈代替幾年前的全職編程。反正它得是在x射線斷層攝影早晨所以如果有人打破這個代碼下來對我來說我(和我可憐的朋友)將永遠感激..這是做什麼var index_num:Number = 1; var numFrames:int = this.dances_mc.totalFrames; (AS3)

這是什麼線做的事:

VAR numFrames:INT =此。 dances_mc.totalFrames;

在時間軸的第一幀有一個叫做dances_mc的符號,其中有5個左右的幀和一個停止函數。每個框架都包含不同的文字和圖像。有一個完整的演示,其中按鈕導致文本和圖像改變,並在最後循環。

文件中的AS看起來是這樣的:

trace("movie starts"+this.dances_mc.totalFrames); 

var index_num:Number= 1; 
var numFrames:int = this.dances_mc.totalFrames; 

// Your code goes here 

stop(); 

我需要編寫一個事件處理程序,顯示下一個舞蹈每個按鈕被按下的時間。然後改進事件處理程序,以便一旦顯示最後一個舞蹈,按下按鈕將再次顯示第一個舞蹈。

在此先感謝!

回答

1

有問題的線路正在告訴您該影片剪輯中有多少幀,因此您可以知道何時循環回第一幀。

代替你//你的代碼放在這裏:

function nextDance(e:MouseEvent = null):void { 
    index_num++; //increment your current index when the button is clicked 
    if(index_num > numFrames){ //if your index is higher than the total amount of frame, go back to the first one 
     index_num = 1; 
    } 
    this.dances_mc.gotoAndStop(index_num); //go to the frame of the new current index; 
} 

yourButton.addEventListener(MouseEvent.CLICK,nextDance,false,0,true); 
+0

這是偉大的感謝! :) – 2012-08-16 19:01:17