PDA

View Full Version : Frame control on mouseover/click (urgent)



joshcaple
May 19th, 2009, 12:06 PM
I've been brought in at the last minute to finish off someone elses code on a project and having some trouble getting something to work....
The following is from an AS3 applet which slides 4 panels, populated with photos & links from the CMS. I need the timer to pause & reset when I rollover the tab that is open at the time. I onlny have a couplle hours to figure this out!
Thanks for your help,
J



var tempo:Timer = new Timer(7000);
tempo.addEventListener(TimerEvent.TIMER, nextTAB);
function nextTAB(evt:TimerEvent):void
{
switch (superID)
{
case 1 :
moveTAB2();
break;
case 2 :
moveTAB3();
break;
case 3 :
moveTAB4();
break;
case 4 :
moveTAB2();
break;
}
}
function resetLoopTAB()
{
tempo.stop();
timer_preload.gotoAndPlay(1);
tempo.start();
}
tempo.start();

ahmednuaman
May 19th, 2009, 01:28 PM
Use setTimeout instead: http://livedocs.adobe.com/flash/9.0/ActionScriptLangRefV3/flash/utils/package.html#setTimeout()

cbeech
May 19th, 2009, 02:41 PM
yeah that'll work - but i would still favor Timer, since you'd have to use clearTimeout in the event of a change and then set a new timeout.

in the posted code above instead of using tempo.stop() - use: tempo.reset();
this will both stop the timer and reset the currentCount property to 0, so that the timer moves through the entire interval. when you use stop, the timer will start at the 'previously' stopped count, which will cause it to fire previous to the full elapsed interval.

i would also consider using tempo.start() from within your rollout handler.

joshcaple
May 21st, 2009, 12:37 PM
THanks guys!