动作游戏

时间:2014-10-29 20:27:05

标签: actionscript

获取这些错误V:\ Users \ documents - Lab1_resources \ start \ MainTimer.as,Line 21 1120:访问未定义的属性currentMin。 和 V:\ Users \ documents - Lab1_resources \ start \ MainTimer.as,第31行1120:访问未定义的属性onTimerComplete。

包{

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
}   

}

1 个答案:

答案 0 :(得分:0)

每当actionScript编译器找不到指定的属性时,它就会用编译器错误1120标记它。 currentMinonTimerComplete是您违规财产的名称。