I’m trying to create a loop of a phone that rings every 5 seconds using the Timer Class.
The problem I have is when it gets to function stopRing and noRingTimer.start(); it goes backs to function onTimerComplete not the start.
package {
import flash.display.*;
import flash.events.*;
import flash.events.TimerEvent;
import flash.utils.Timer;
public class Phone extends MovieClip {
var noRingTimer:Timer = new Timer(1000, 5);
var ringTimer:Timer = new Timer(400, 8);
public function Phone() {
mPhoneScreen.visible = false;
noRingTimer.addEventListener(TimerEvent.TIMER_COMPLETE, onTimerComplete);
ringTimer.addEventListener(TimerEvent.TIMER, ring);
ringTimer.addEventListener(TimerEvent.TIMER_COMPLETE, stopRing);
noRingTimer.start();
}
public function onTimerComplete(evt:TimerEvent):void {
trace("Start ring!");
ringTimer.start();
}
public function ring(evt:TimerEvent):void {
mPhoneScreen.visible = !mPhoneScreen.visible;
trace( "ring " + evt.target.currentCount)
}
public function stopRing(evt:TimerEvent):void {
noRingTimer.start();
trace("stop ring")
}
}
}