@player_03: Tried your suggestions, but it does not resolve it. I have got to set an ID to that timers and specifically stop that Timer. In my set up, there are multiple objects running at once, each using the same function but passes different arguments. When this all fires up many many times, the flash players set ups multiple Timer for one Object only, messing animations up. What should happen is, the Time should get deleted when a new Timer tries to animate the same object. I did it in AS3 using the code below:
I prevent messing up setInterval()
by doing this in AS3:
intervaliDs:Array = new Array();
function new(){
myObj1.addEventListener(MouseEvent.MOUSE_OVER, starter);
otherObj.addEventListener(MouseEvent.MOUSE_OVER, starter);
myObj2.addEventListener(MouseEvent.MOUSE_OVER, starter);
somethingElseClip.addEventListener(MouseEvent.MOUSE_OVER, starter);
}
function starter (e:MouseEvent){
initializer(e.currentTarget, [other vars]);
}
function initializer (mc:Object,[other vars]){
clearInterval(intervaliDs[mc.name])
function animateThis(){
// some code here
//clearInterval() when some condition is meet
}
intervaliDs[mc.name] = setInterval(animateThis,20);
}
so when this code is fired, the clearInterval() will specifically clear the setInterval() that was binded to mc.name. So in a way, no setInterval is left running in the background that would do its own animation.
Now I am converting all my code to Haxe, so no setInterval was implemented there, I got to animate using ENTER_FRAME or Timer.
I have tried to set an iD to Timer Events by placing them on an Array. There were some left over animation (Messed up), I could not clear them specifically since Timer.stop() stops only the recent Timer.start().
So here is the summary of my code using Timer (no iDs)
function new(){
myObj1.addEventListener(MouseEvent.MOUSE_OVER, starter);
otherObj.addEventListener(MouseEvent.MOUSE_OVER, starter);
myObj2.addEventListener(MouseEvent.MOUSE_OVER, starter);
somethingElseClip.addEventListener(MouseEvent.MOUSE_OVER, starter);
}
function starter (e:MouseEvent){
initializer(e.currentTarget, [other vars]);
}
function initializer (mc:Dynamic,[other vars]){
stop() //this is a problem! you cannot fire this up. it trows error.
var myTimer = new Timer(20,100);
function animateThis(e:TimerEvent){
// some code here
//stop() timer when some condition is meet
}
myTimer.addEventListener(TimerEvent.TIMER,animateThis);
myTimer.start();
}
So when we move the mouse over those object very fast and many times, you got myTimer.start() and myTimer.stop() firing at any moment. Animation stucks up and resumes, and so on. If only I could properly set an identifier to each myTimer.start() and then clear it specifically with myTimer.stop(), things will get resolve. BTW using Arrays to store them did not work in this case.