Skip to main content
Participant
June 15, 2013
Answered

How to stop a timer from another class?

  • June 15, 2013
  • 1 reply
  • 392 views

Hi I'm trying to stop a timer in stopwatch class from MainMenu class. But my code doesn't work, here is my code:

in MainMenu class i've method:

public function pauseGame (e:MouseEvent){

     timestop = new Stopwatch();

     timestop.Stoptimer(); }

in class Stopwatch i try to stop my timer with:

public function Stoptimer(){

      timer.stop();

      timer.removeEventListener(TimerEvent.TIMER, timeFun);

      return; }

This topic has been closed for replies.
Correct answer Ned Murphy

You need to pass a reference to the Timer to the Stoptimer class.

1 reply

Ned Murphy
Ned MurphyCorrect answer
Legend
June 15, 2013

You need to pass a reference to the Timer to the Stoptimer class.