【问题标题】:Flash - On Timer Private FunctionFlash - On Timer 私人功能
【发布时间】:2013-03-10 17:17:03
【问题描述】:

我正在尝试为这个游戏设置一个计时器。我在第 36 行收到错误:私有属性只能用于类属性定义。

这是硬件作业的最后一部分供您比较:http://www.lwebdesigns.net/hw1.docx

这是我的 MainTimer 的代码 包{

import flash.display.MovieClip;

import flash.events.TimerEvent;
import flash.utils.Timer;


public class MainTimer extends MovieClip {
    // Init vars for class
    private var currentMin:int;
    private var currentSec:int;
    // create a one second timer from Flash's Timer class
    private var oneSecTimer:Timer = new Timer(1000,1);

    public var timerHasStopped:Boolean = false;

    public function MainTimer() {
        // constructor code
        trace("Main timer is here");
        currentMin = 2;
        currentSec = 5;

        minBox.text = String(currentMin);
        if(currentSec < 10){
            secBox.text = "0" + String(currentSec); //concatenate with a leading zero
           }else{
               secBox.text = String(currentSec);
           }//if end
           oneSecTimer.addEventListener(TimerEvent.TIMER_COMPLETE, onTimerComplete);
           oneSecTimer.start();

    } // ends onTimerComplete

} //public function maintimer end
        private function onTimerComplete(event:TimerEvent):void{

        currentSec = currentSec - 1;

        if (currentSec < 0){
            currentSec = 59;
            currentMin -= 1;
        } //end if
        if (currentMin < 0){
            currentMin = 0;
            currentSec = 0;
            timerHasStopped = true;
        }else{
            oneSecTimer.start();
        } //end else

        //update our display
        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
    }// end onTimerComplete

} //公共端 } //打包结束

【问题讨论】:

    标签: flash function timer private


    【解决方案1】:

    据我所知,您有很多 }。删除有评论的那条

    }//public function maintimer end

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2021-08-05
      • 2021-11-15
      相关资源
      最近更新 更多