I've also been confused by this in the past so I thought I'd try and
qualify for myself and I think the explanation is fairly straight forward...
It depends on whether the reference in question is expected to be a
standard JS Function (Object) or a specialised Object created by
Prototypes' Class.create().
Creating an object with Class.create() forces Prototype to call the
`initialize' method upon construction (mimicking Ruby syntax),
presumably to encapsulate state etc. You can still make reference to the
effect (e.g Effect.Opacity) without constructing the object first but
without initialisation you can't expect it to work. Be nice if this was
more consistent but that's the nature of the beast..
From the source code for examples you quoted ;
new Insertion.Before (...);
[ Insertion.Before = Class.create();]
new Effect.Opacity(...)
[Effect.Opacity = Class.create();]
Effect.Fade(..);
[Effect.Fade = function(element) {....}]
Effect.Appear(...);
[Effect.Appear = function(element) {...}]
So I guess, as you say, that latter are just static calls and the former
RELY upon state in object instantiation..
HTH
Matt
Ryan Gahl wrote:
Well then I guess I was wrong :-)
Just do what works and call it magic :-)
On 6/14/06, *Reynard Hilman* < [EMAIL PROTECTED]
<mailto:[EMAIL PROTECTED]>> wrote:
Thanks for the explanation. The functions that require
instantiation won't work if you just call the function though.
Hmm, I'm pretty sure they can all be used either way, since
functions are
first class objects (you can either invoke or instanstiate, and
instantiation also causes invocation of the constructor, which
in this case
is also the meat and potatoes)...
I think instantiation of the Effects, et. al., depends on
whether or not you
need a handle to it for some other purpose later, or maybe for
settings/memory re-use.
_______________________________________________
Rails-spinoffs mailing list
[email protected]
<mailto:[email protected]>
http://lists.rubyonrails.org/mailman/listinfo/rails-spinoffs
------------------------------------------------------------------------
_______________________________________________
Rails-spinoffs mailing list
[email protected]
http://lists.rubyonrails.org/mailman/listinfo/rails-spinoffs
_______________________________________________
Rails-spinoffs mailing list
[email protected]
http://lists.rubyonrails.org/mailman/listinfo/rails-spinoffs