2013-04-28 65 views
0

我目前有一個帶有實例名稱「powerbar」的MovieClip。它總共有6個幀,並且根據特定的標準,我希望它顯示特定的幀。這裏是我的代碼:MovieClip沒有顯示正確的幀

  if(char.throwing) { 
      var pressLength:Number = getTimer()-startPress; 

      if(pressLength >= 400) { 
       powerbar.gotoAndPlay(6); 
       trace("more than 400 " +String(powerbar.currentFrame)); 
      } 
      else if(pressLength >= 300) { 
       powerbar.gotoAndPlay(5); 
       trace("more than 300 " +String(powerbar.currentFrame)); 
      } 
      else if(pressLength >= 200) { 
       powerbar.gotoAndPlay(4); 
       trace("more than 200 " +String(powerbar.currentFrame)); 
      } 
      else if(pressLength >= 100) { 
       powerbar.gotoAndPlay(3); 
       trace("more than 100 " +String(powerbar.currentFrame)); 
      } 
      else if(pressLength >= 50) { 
       powerbar.gotoAndPlay(2); 
       trace("more than 50 " +String(powerbar.currentFrame)); 
      } 
      else if(pressLength >= 25) { 
       powerbar.gotoAndPlay(1); 
       trace("more than 25 " +String(powerbar.currentFrame)); 
      } 
      else if(pressLength >= 0) { 

       powerbar.gotoAndPlay(1); 
      } 

它編譯罰款,也有在運行時沒有錯誤,我甚至檢查,看看是否我的if語句取決於什麼,我需要在這裏工作,我確信我被引用正確的影片剪輯(我追蹤了影片剪輯的x位置,這是正確的)。我甚至通過追蹤(power bar.currentFrame)來追蹤它是否進入該幀,並且顯示它已經進展到該幀,儘管它沒有在動畫中顯示。 我也嘗試gotoAndStop,它仍然沒有工作...請幫助!

+1

gotoAndStop而不是gotoAndPlay? – 2013-04-28 18:50:31

+0

我在一開始就試過,它沒有工作,我現在只是改變了它,但它仍然不起作用 – Erika 2013-04-28 19:01:24

+0

你的錯誤在代碼之外。意思是你可能做了其他的事情是錯誤的。您很可能誤解了動畫在Flash中的工作方式。或者當你開始動畫時你認爲會發生什麼。或者powerbar沒有鏈接到正確的動畫片段,或者presslength不會在調用之間重置,或者完全不同的是錯誤的。我想說的是,該代碼沒有任何問題,因此沒有人能夠幫助你實現你想要的解釋。 – 2013-04-28 22:27:07

回答

0
 var pressLength:Number = getTimer()-startPress; 

     //enterFrame/or keypress function here:) 
     if(char.throwing) { 
     throwing_function(); 
     } 

     function throwing_function(){ 
     if(pressLength >= 25 && pressLength<=49) { // check both conditions 
      powerbar.gotoAndStop(2); 
      trace("more than 25 but less than 50") 
      trace(pressLength.toString) // i think 
     } 
     else if(pressLength >= 50 && pressLenght<=74) {check both conditions are good 
      powerbar.gotoAndStop(3); 
      trace("more than 50 but less than 75 ") 
     } 
     } 

     etc...... 

但有更好的方法可以解決這個,我想我會用你的主題

堅持通過檢查你的問題只有一個條件,我犯了這個錯誤很長一段時間前的一個進度條裝資產。