Please help? Stack of timers

Hi all,

I’m making a game where you can have stacks of similar effects on a character. For example, when hit by X attack, a character’s damage decreases by 10% for 5 seconds, or when hit by Y attack, its damage decreases by 40% for 2 seconds, etc.-these percentages and durations could be anything.

I intend for these effects to sometimes overlap in time, but not be additive/multiplicative. That is, only the biggest decrease goes into effect whenever more than one exists at a time.

Obviously I need a simple stack/array of dynamically created timers, which is easy enough- but my problem is how to handle the fact that these timers of the same type use the same handler function when the timer ends and the handler event happens, and what to put in that function, since it doesn’t inherently “know” which timer it came from. Pushing into an array and searching for the largest modifier is easy, but if I just use an array and push/pull/etc, I can’t figure out how to get it to pull from the stack accurately since the right one isn’t always at the beginning or end…

The following is what I had working before I tried to implement the array of timers (which I’ve tried to do in multiple ways)- this implementation obviously doesn’t work right - here, when any one damage timer ends, the modifier gets set back to 1, whether or not other timers are counting down.

Thank you for any words of advice.

private var damageModifier:Number=1;

public function loop() : void

public function adjustDamage(modifier:Number, duration:Number) : void
damageTimer = new Timer (duration, 1);
damageTimer.addEventListener(TimerEvent.TIMER, damageTimerHandler, false, 0, true);
addEventListener(Event.ENTER_FRAME, loop, false, 0, true);

private function damageTimerHandler(e:TimerEvent) : void