Hi,

Below is a patch to PeriodicalExecuter that should do what your
asking, I have Prototype 1.7.min and this patch is untested:

var
PeriodicalExecuter=Class.create({initialize:function(callback,frequency)
{this.callback=callback;this.frequency=frequency;this.currentlyExecuting=false;this.iterations=0;this.registerCallback()},registerCallback:function()
{this.timer=setInterval(this.onTimerEvent.bind(this),this.frequency*1000)},execute:function()
{this.callback(this)},stop:function(){if(!
this.timer)return;clearInterval(this.timer);this.timer=null},onTimerEvent:function()
{if(!this.currentlyExecuting)
{try{this.currentlyExecuting=true;this.iterations+
+;this.execute();this.currentlyExecuting=false}catch(e)
{this.currentlyExecuting=false;throw e}}}});

I suggest you make a backup of your current prototype implementation
if you have made any other modifications to it.

Replace the current PeriodicalExecuter class with the one above.

To find out what iteration PE is on just call 'pe.iterations', 'pe'
being the variable name of the argument supplied to the callback
function.

Or to find out from outside of the callback just use 'pe.iterations',
in this case 'pe' being the variable name in which the implementation
of PeriodicalExecuter is stored.

Hope this helps.

Cheers,

Chris

Oh and Merry Christmas.

On Dec 18, 11:20 am, JoJo <tokyot...@gmail.com> wrote:
> What's the best way to find which iteration the PeriodicalExecutuer is
> currently on? What I'm trying to do is step through an array slowly
> (period of 0.5 seconds) and having the ability to stop at an arbitrary
> time. The PeriodicalExecuter has the ability to stop, but it doesn't
> have the ability to step sequentially through an array. Or should I
> not even attempt to use PE's for this?

-- 
You received this message because you are subscribed to the Google Groups 
"Prototype & script.aculo.us" group.
To post to this group, send email to prototype-scriptacul...@googlegroups.com.
To unsubscribe from this group, send email to 
prototype-scriptaculous+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/prototype-scriptaculous?hl=en.

Reply via email to