PDA

View Full Version : Example: Technique for Multiple timer events


holtgrewe
12-14-2006, 01:47 PM
Here is a technique I use for multiple timed events on a page. This is another example of how versatile AMS6 is in developing APs.


ON PRELOAD:
-- >>>>> setup timer invervals for firing multiple timed events.
-- >>>>> set up 6 timers
myTimers_Max=6
-- >>>>> set up a duration for when each timer should be fired
myTimers_Duration={500,1000,1200,750,4000,2000}
-- >>>>> Set up an interval counter for each timer
myTimers_Interval={0,0,0,0,0,0}
Page.StartTimer(100);
pgTimer_Counter=100


ON TIMER:
-- >>>>> increment the interval for each timer
for x = 1, myTimers_Max do
myTimers_Interval[x] = myTimers_Interval[x] + pgTimer_Counter
end

-- >>>>> check if Individual timer event should be fired
for x = 1, myTimers_Max do
if myTimers_Interval[x] >= myTimers_Duration[x] then
myTimers_Interval[x] = 0; --clear the interval counter & get ready for next time
myTimer_Funct(x); -- execute the function for timer [x]
end
end

--Global Function:
function myTimer_Funct(whichTimer)
if whichTimer == 1 then -- Timer 1 has fired
-- >>>>> timer1 scripting
end
--etc. for the other timers

Imagine Programming
07-21-2008, 09:56 AM
Nice example, thanks!

Worm
07-21-2008, 10:05 AM
I too have used a similar method, the only drawback is that if a certain timer interval has more than one function firing from it they are delayed while each function is processed. If you're not doing anything *heavy* within the function, it works great.

ShadowUK
07-21-2008, 10:32 AM
Woah at the two year bump. Nice method though.

qwerty
08-07-2008, 04:44 PM
Woah at the two year bump. Nice method though.

:eek: :lol

thats pretty impressive, and i thought i was bad for resurecting threads :p

bule
08-07-2008, 05:00 PM
Well at least he is browsing the forum. Nothing wrong with the revival.

RizlaUK
08-07-2008, 06:10 PM
yup, remember the days when we only had 1 timer per page .. .. .. lmao

Esfahan
08-08-2008, 05:07 AM
Hello
oh, please attache a sample that how to use this codes ;;;
I can't use it:o

RizlaUK
08-08-2008, 07:35 AM
Esfahan, the are easyer and more reliable timer methods on the forum, this is a pure ams workaround but its not ideal for heavy timer work

all the below timers solutions are bug free, reliable and vista compatable :yes
http://www.indigorose.com/forums/showthread.php?t=24392&highlight=timer+plugin
http://www.indigorose.com/forums/showthread.php?t=24379&highlight=timer+plugin
http://www.indigorose.com/forums/showthread.php?t=24383&highlight=timer+plugin

holtgrewe
08-08-2008, 08:18 AM
Esfahan
I've attached an example of something I did awhile ago. Keep in mind that this technique is fine as long as there is not a lot of extensive processing within the timer event, where the single timer can't keep up with the processing.
It does work; however I have personally switched to using one of the multiple timer options mentioned in the RizlaUK post.

Esfahan
08-08-2008, 08:46 AM
@Rizla
THX , if AMS self have been a multi timer it be beter, but your plugin is very well:yes
@holtgrewe
THX , I will check it:yes

RizlaUK
08-08-2008, 09:04 AM
personaly speaking, unless your project already uses luaCOM then i would use retesets timer plugin :yes

if AMS self have been a multi timer it be beter

yeah, maybe, but with all the timer options around i would rather see IR work on something that hasent been coverd by a plugin, there are many many things that AMS still lacks.

qwerty
08-08-2008, 09:17 AM
yes, they need to make use of the community... if the community finds a solution for something and it works well, then IR can spend more time working on things the community wants but cant be done from plugins etc ;) (function selectable page transitions anyone ! :lol:lol:lol ... improved security maybe ?)

Esfahan
08-08-2008, 11:15 AM
@Rizla
OK, Your luacom method same is a good plugin.:yes

@holtgrewe
very very good project.
it is cool materiel for AMS multi timer without any plugin.
thanks for share your method.

too, it has a new idea for display timer actions.:yes