0

我有两个名为“main”和“TimerCountDown”的类。我试图从“主”类中的“TimerCountDown”调用单个函数“重置”。

这是我的 TimerCountDown 类:

public class TimerCountDown extends MovieClip
    {   
        public function TimerCountDown(t:TextField, timeType:String, timeValue:Number, es:String, _documentclass):void
        {
            this.documentclass = _documentclass;
            this.tfTimeDisplay = t;
            if (timeType == "seconds")
            {
                this.timeInSeconds = timeValue;
            }
            if (timeType == "minutes")
            {
                this.timeInSeconds = timeValue * 60;
            }
            this.tfEndDisplayString = es;
            this.startTimer();
        }
            public function reset():void{
            clockCounter.reset();
        }
}

如何在主类中创建引用使用主类函数中的重置功能?我只能做某事

var myTimerObject:TimerCountDown = new TimerCountDown(timer, "seconds", 40, "0!", this);

但不知道调用重置功能。

4

2 回答 2

0

你可以这样称呼它:

myTimerObject.reset();
于 2013-09-25T03:18:55.080 回答
0

您可以在主类中保留 myTimerObject 的引用

public class Main {


   private var _targetTimerObject:TimerCountDown;

   public function set targetTimerObject(value:TimerCountDown):void {

        _targetTimerObject = value;
   }

   public function someFunction():void {

       if (_targetTimerObject) {
           _targetTimerObject.reset();
       }
   }

}
于 2013-09-25T04:00:51.903 回答