How can I store an effect into one array without execute it? When I try this, the effect executes at the same time it stores in the array var myarray = new Array(); myarray.push(new Effect.Appear(''midiv'')); Thanks to all! --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
new Effect.XXX will create a new effect that is executed immediately, regardless of where you store the reference to it. If you want to predefine effects for repeated reuse, you can do (from my head, untested code!): var myeffects = [ [Effect.Appear, ''mydiv'', { duration: 2.0} ], [Effect.Fade, ''otherdiv'', { duration: 1.2} ] ]; and later do: myeffects.each(function(effect){ new effect[0](effect[1],effect[2]) }); Note that this could probably be written in a much nicer wa. Best, Thomas Am 13.12.2006 um 10:26 schrieb Javier Martinez:> How can I store an effect into one array without execute it? > > When I try this, the effect executes at the same time it stores in > the array > > var myarray = new Array(); > myarray.push(new Effect.Appear(''midiv'')); > > Thanks to all! > > >--~--~---------~--~----~------------~-------~--~----~ 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 would store anonymous functions in the array like var myarray = new Array(); myarray.push(function(){ new Effect.Appear(''midiv'') }); Then execute one of the functions like myarray[0]() --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
Thanks Thomas, but I try to store the effects for use them on Effect.Parallel later. At this time I''m making a string with the code and execute them with "eval", but it''s weird. There is another way to make this to prepare for Effect.Parallel? Thanks again! 2006/12/13, Martin Bialasinski <klingeling-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>:> > > I would store anonymous functions in the array like > > var myarray = new Array(); > myarray.push(function(){ new Effect.Appear(''midiv'') }); > > Then execute one of the functions like myarray[0]() > > > >--~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
that''s a bit more complicated-- if you want to reuse the array (that is calling Effect.Parallel more than once), you can use: var myeffects = [ [Effect.Appear, ''mydiv'', { /* options for appear */ } ], [Effect.Fade, ''otherdiv'', { /* options for fade */ } ] ]; and later do: new Effect.Parallel( myeffects.map(function(effect){ return new effect[0](effect[1], Object.extend(effect[2], { sync: true})); }, { duration: 2.0 }); again, from the top of my head. you might also want to investigate the anonymous functions technique outlines by martin. best, thomas Am 13.12.2006 um 15:10 schrieb Javier Martinez:> Thanks Thomas, but I try to store the effects for use them on > Effect.Parallel later. > At this time I''m making a string with the code and execute them > with "eval", but it''s weird. There is another way to make this to > prepare for Effect.Parallel? > > Thanks again! > > > 2006/12/13, Martin Bialasinski <klingeling-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>: > I would store anonymous functions in the array like > > var myarray = new Array(); > myarray.push(function(){ new Effect.Appear(''midiv'') }); > > Then execute one of the functions like myarray[0]() > > > >--~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---