Hi everybody, I have this loop that loops through the the number of pictures to be in a slide show. Too handle when a photo should appear and when it should disappear I''m using the PeriodicalExecuter. Heres the code: var photo = null; for (var i=0;i<loop_length;i++) { if (i == 0) { var exe_time = 1; } else { var exe_time = (i * 8); } photo = ''photo''+i; new PeriodicalExecuter( function(pe) { pe.stop(); $(photo).setStyle({display: ''block''}); new Effect.Opacity(photo, {duration:1.0, from:0.0, to: 1.0, afterFinish: end_show}); function end_show() { new Effect.Opacity(photo, {delay:4.0, duration:1.0, from:1.0, to:0.0, afterFinish: function() {$(photo).setStyle({display: ''none''})}}); } }, exe_time); } I''m wondering if you can have more than one PeriodicalExecuter? Thanks for any help --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Spinoffs" group. To post to this group, send email to rubyonrails-spinoffs-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-spinoffs-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-spinoffs?hl=en -~----------~----~----~----~------~----~------~--~---
> I''m wondering if you can have more than one PeriodicalExecuter?Why not? Did you try and it didn''t work for you? Having more than one PeriodicalExecuter is a fairly normal, and not something I''ve ever run into problems with. All they really are is window.setInterval() calls, and there is no limit to the number of those you can have on a page. -justin --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Spinoffs" group. To post to this group, send email to rubyonrails-spinoffs-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-spinoffs-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-spinoffs?hl=en -~----------~----~----~----~------~----~------~--~---
andymadonna a écrit :> I''m wondering if you can have more than one PeriodicalExecuter?Actually you do. Looking at your code, you create one PE per loop cycle, and they all start by immediately stopping themselves, so they only run once. In short, you don''t use the Periodical part at all. You just use timeouts. You''d probably be better off reverting to native setTimeout calls, then. Oh, and one more thing: instead of setting all the timeouts at once, you may want to only set the next one, which will do its task, then prep the one after it. This lets you use afterFinish callbacks on your effects, for instance, to provide constant intervals between pictures being actually seen. If you prep the timeouts all at once when starting, and a few pictures take a long time to load, you may end up seeing those too a short time. -- Christophe Porteneuve a.k.a. TDD "[They] did not know it was impossible, so they did it." --Mark Twain Email: tdd-x+CfDp/qHev2eFz/2MeuCQ@public.gmane.org --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Spinoffs" group. To post to this group, send email to rubyonrails-spinoffs-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-spinoffs-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-spinoffs?hl=en -~----------~----~----~----~------~----~------~--~---
Hi Justin and Christophe! Thanks for your help! I think I''m going to try the already builtin setTimout like Christophe suggested. I will also try using the afterFinish to load the image. I never thought about what would happen if the image took to long to load. Thanks again! --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Spinoffs" group. To post to this group, send email to rubyonrails-spinoffs-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-spinoffs-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-spinoffs?hl=en -~----------~----~----~----~------~----~------~--~---