Control animation play() and stop() from class
Hello,
I have created some functions to manage timed pause/play in an animation and I am trying to make a class from them, but it does not work, the play() and stop() functions I use have no effect. The functions work as intended when not in the class.
Here is my code:
package anim {
import flash.utils.Timer;
import flash.events.TimerEvent;
import flash.display.MovieClip;
public class Case extends MovieClip {
public var tempsMulti:Number = 1.0;
public function Case():void {
trace("init");
stop();
}
public function setTempsMulti(temps:Number):void {
this.tempsMulti = temps;
}
public function attends(tps:Number):void {
trace("attends");
var temps:Number = tps * this.tempsMulti;
var timer:Timer = new Timer(temps, 1);
stop();
timer.addEventListener("timer", this.suivant);
timer.start();
}
private function suivant(event:TimerEvent):void {
trace("suivant");
play();
}
}
}
I checked that the functions are executed with the trace() and it is the case, so the problem really comes from the play() and stop() functions, and I do not receive any error at compilation or runtime.
Thanks for your help.