Yeah... it probably should be. Class.Mutators aren't documented at all.

As a generally rule all Class.Mutators can only be used once within a class.
The is because once a Mutator is called, the property (Mutator) is removed
from the class/object. So if you have multiple calls to the same Mutator,
only one will be called. Specifically if you look at the code for
Class.Mutators.Implements:

  Implements: function(self, klasses){
      $splat(klasses).each(function(klass){
          $extend(self, ($type(klass) == 'class') ? new klass($empty) :
klass);
      });
  },

You'll see that Implements makes sure that the klasses argument is in array
form by using $splat <http://mootools.net/docs/Core/Core#splat>.

There is only one other Class.Mutators within the core build of Motools,
Extends. Extends only accepts a single argument (a class). It cannot handle
an array of arguments.

If you want more information of Mutators Jan has written a couple of
excellent articles on them at http://blog.kassens.net/.

I myself have played around with Mutators as well and have posted some of my
findings at http://www.nwhite.net/




On Thu, Oct 16, 2008 at 6:18 AM, stratboy <[EMAIL PROTECTED]> wrote:

>
> Ok, found the solution:
>
> if you implement more than 1 class into your new class, you must use
> this sintax:
>
> Implements: [Chain,Events]
>
> It seems that nobody wrote this little thing in the docs... I'm
> wondering why...
>
>
>
>
>
>
>
>
>
> On 16 Ott, 12:03, stratboy <[EMAIL PROTECTED]> wrote:
> > Hi, It seems that if I implement Chain AND Events in the same class,
> > Chain doesn't work anymore.
> > For exemple the class below works properly, but as soon as I add
> > Implements:Events, the chain methods don't work anymore. I need Events
> > because I want to fire out an event when the last fx of the chain is
> > complete.
> > I think i'm doing something wrong implementing the Events, so, can you
> > help me please?
> >
> > ////////////////////////////////////////
> >
> > var Switcher = new Class({
> >
> >         Implements:Chain,
> >         Implements:Events,
> >
> >         initialize:function(){
> >
> >                 this.elem1 = null;
> >                 this.elem2 = null;
> >                 this.currentElement = null;
> >
> >         },
> >
> >         switchElements:function(elem1,elem2){
> >
> >                 this.elem1 = $(elem1);
> >                 this.elem2 = (elem2) ? $(elem2) : null;
> >
> >                 if(!elem2){
> >                         this.elem1.set('tween',{ link:'chain' });
> >                         this.showElement1(this.elem1);
> >                 }
> >
> >                 else{
> >                         this.clearChain();
> >
> >                         this.elem1.set('tween',{ link:'chain' });
> >                         this.elem2.set('tween',{ link:'chain',
> onComplete:function()
> > { this.callChain(); }.bindWithEvent(this) });
> >
> >                         this.chain(
> >                                 function(){ this.fadeElement2(); },
> >                                 function(){ this.hideElement2(); },
> >                                 function(){ this.showElement1(); }
> >                         );
> >
> >                         this.callChain();
> >                 }
> >         },
> >
> >         showElement1:function(){
> >
> > this.elem1.setStyles({ 'opacity':'0','display':'block'
> }).tween('opacity',
> > 1);
> >         },
> >
> >         fadeElement2:function(){
> >                 this.elem2.tween('opacity',0);
> >         },
> >
> >         hideElement2:function(){
> >                 this.elem2.setStyles({'display':'none'});
> >                 this.callChain();
> >         }
> >
> >         ///////
> >
> > });
>

Reply via email to