2014-10-29 60 views
0

獲取這些錯誤V:\ Users \ documents - Lab1_resources \ start \ MainTimer.as,第21行1120:訪問未定義的屬性currentMin。 和 V:\ Users \ documents - Lab1_resources \ start \ MainTimer.as,31行1120:訪問undefined屬性onTimerComplete。actionscript遊戲

包{

import flash.display.MovieClip; 
import flash.events.TimerEvent; 
import flash.utils.Timer; 
//import flash.events.ThrottleEvent; 

public class MainTimer extends MovieClip { 

    private var currentMin:int; 
    private var currentSec:int; 

    private var oneSecondTimer:Timer = new Timer(1000); 
    public var timerHasStopped:Boolean = false; 

    public function MainTimer() { 
     // constructor code 
     trace("the Main Timer is here"); 
     currentMin = 1; 
     currentSec = 5; 

     minBox.text = String(currentMin); 
     if(currentSec < 10) { 
      secBox.text = "0" + String(currentSec); 
     }else{ 
     secBox.text = String(currentSec); 
    } 
    oneSecondTimer.addEventListener(TimerEvent.TIMER, onTimerComplete);  
    oneSecondTimer.start(); 
    } 

    private function onTimerComplete(event:TimerEvent):void{ 

     trace("TIMER HAS STARTED. COUNTING DOWN.......");   

     currentSec = currentSec - 1; 
     if (currentSec < 0){ 
      currentSec = 59; 
      currentMin = currentMin - 1; 
     } 
     if(currentMin < 0) { 
      currentMin = 0; 
      currentSec = 0; 
      resetTimer(); 
     } 

     minBox.text = String(currentMin); 
     secBox.text = String(currentSec); 
     if(currentSec < 10){ 
      secBox.text = "0" + String(currentSec); 
     } 
    } 

    public function resetTimer():void{ 
     oneSecondTimer.removeEventListener(TimerEvent.TIMER, onTimerComplete); 
     trace("TIMER HAS FINISHED. RESETTING......."); 
     //update our display 
     currentMin = 1; 
     currentSec = 5; 
     minBox.text = String(currentMin); 
     secBox.text = String(currentSec); 
     //Adjust display for seconds less than 10 
     if (currentSec < 10){ 
      secBox.text = "0" + String(currentSec); 
     }//end if 
     timerHasStopped = false; 
     //if the timer needs to start again, add the following line of code. 
     oneSecondTimer.addEventListener(TimerEvent.TIMER, onTimerComplete); 

    }//end function 
} 

} 

回答

0

每當ActionScript編譯器無法找到指定的屬性,它的編譯器錯誤標誌是1120 currentMinonTimerComplete是你出錯的屬性的名稱。