O'Reilly logo

MooTools 1.3 Cookbook by Jay Larry G. Johnston

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Upgrading all Corvettes via recall—Implement AND Extend in unison!

But wait, we can do even more with Implements and Extends! Prepare to see them used simultaneously.

Getting ready

Starting off from where our last recipe left off will get us ready.

<h1>Speeds Before</h1>
<div id="before"></div>
<h1>Speeds After</h1>
<div id="after"></div>
// create two classes from the base Class
var Car = new Class({
showSpeed: function() { return 0; }
});
var SportyEngine = new Class({
speed: 10,
showSpeed: function() { return this.speed; }
});
// Extend one, Implement the other
var Corvette = new Class({
Extends: Car,
speed: 1,
showSpeed: function() {
// this.parent calls the overridden class
return this.parent()+1;
}
});

How to do it...

In this example, we want ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required