Skip to main content
Known Participant
August 23, 2011
Answered

Timer question, is this possible?

  • August 23, 2011
  • 1 reply
  • 706 views

Hello!

Question is about timer.

Can I add event to click handler event that makes timer become smaller?

Damn, I can't explain the thing I need!

OK I will try different way!

The thing is I need to click objects and every time I click on object time between flashing objects become smaller and objects apear on stage faster with each click on them.

I hope this will help to understand my problem.

This topic has been closed for replies.
Correct answer Colin Holgate

Yes, timers have a delay propery. You could do this:

var t:Timer = new Timer(5000,0);

t.addEventListener(TimerEvent.TIMER,dostuff);

addEventListener(MouseEvent.CLICK,shortentimer);

function dostuff(e:TimerEvent){

//do whatever the timer is supposed to do

}

function shortentimer(e:MouseEvent){

t.delay = t.delay * .9;

}

Or something on those lines! Each time the mouse is click the timer's delay would reduce to 90 percent of its previous value.

1 reply

Colin Holgate
Colin HolgateCorrect answer
Inspiring
August 23, 2011

Yes, timers have a delay propery. You could do this:

var t:Timer = new Timer(5000,0);

t.addEventListener(TimerEvent.TIMER,dostuff);

addEventListener(MouseEvent.CLICK,shortentimer);

function dostuff(e:TimerEvent){

//do whatever the timer is supposed to do

}

function shortentimer(e:MouseEvent){

t.delay = t.delay * .9;

}

Or something on those lines! Each time the mouse is click the timer's delay would reduce to 90 percent of its previous value.

playa_12Author
Known Participant
August 23, 2011

Are You sure this is right code?

Cause objects actually apear slower rather than faster.

playa_12Author
Known Participant
August 23, 2011

My bad! Forgot to add "." in front of 9