0

「main」と「TimerCountDown」という 2 つのクラスがあります。「main」クラスの「TimerCountDown」から単一の関数「reset」を呼び出そうとしました。

これは私の 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();
        }
}

メインクラスの関数でリセット機能を使用して、メインクラスで参照を作成するにはどうすればよいですか? 私は sth like しかできません

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 に答える