2013-09-25 3 views
0

'main'과 'TimerCountDown'이라는 두 개의 클래스가 있습니다. 'main'클래스의 'TimerCountDown'에서 'reset'이라는 단일 함수를 호출하려고했습니다.다른 클래스의 메소드 호출하기 Action Script 3

이 내 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처럼 할 수있다.

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

그러나 리셋 기능을 호출하는 것에 관해서는 모른다.

답변

0

이처럼 호출 할 수

myTimerObject.reset(); 
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(); 
     } 
    } 

} 
관련 문제