4 The base Class of the [MooTools](http://mootools.net/) framework.
6 Class Method: constructor {#Class:constructor}
7 ----------------------------------------------
11 var MyClass = new Class(properties);
15 1. properties - Can be one of the following types:
16 * (*object*) The collection of properties that apply to the Class. Also accepts some special properties such as Extends, Implements, and initialize (see below).
17 * (*function*) The initialize function (see below).
19 #### Property: Extends
21 * (*class*) The Class that this class will extend.
23 The methods of this Class that have the same name as the Extends Class, will have a parent property, that allows you to call the other overridden method.
24 The Extends property should be the first property in a class definition.
26 #### Property: Implements
28 * (*class*) The properties of a passed Class will be copied into the target Class.
29 * (*array*) An array of Classes, the properties of which will be copied into this Class.
31 Implements is similar to Extends, except that it adopts properties from one or more other classes without inheritance.
32 Useful when implementing a default set of properties in multiple Classes. The Implements property should come after Extends but before all other properties.
34 #### Property: initialize
36 * (*function*) The initialize function will be the constructor for this class when new instances are created.
38 #### Property: toElement
40 * (*function*) A method which returns an element. This method will be automatically called when passing an instance of a class in the [document.id][] function.
45 * (*class*) The created Class.
52 initialize: function(name){
56 var myCat = new Cat('Micia');
57 alert(myCat.name); // alerts 'Micia'
60 initialize: function(){
67 var Animal = new Class({
68 initialize: function(age){
74 initialize: function(name, age){
75 this.parent(age); // calls initalize method of Animal class
79 var myCat = new Cat('Micia', 20);
80 alert(myCat.name); // alerts 'Micia'.
81 alert(myCat.age); // alerts 20.
83 #### Implements Example:
85 var Animal = new Class({
86 initialize: function(age){
92 setName: function(name){
96 var myAnimal = new Cat(20);
97 myAnimal.setName('Micia');
98 alert(myAnimal.name); // alerts 'Micia'.
103 Class Method: implement {#Class:implement}
104 ------------------------------------------
106 Implements the passed in properties into the base Class prototypes, altering the base Class.
107 The same as creating a [new Class](#Class:constructor) with the Implements property, but handy when you need to modify existing classes.
111 MyClass.implement(properties);
115 1. properties - (*object*) The properties to add to the base Class.
119 var Animal = new Class({
120 initialize: function(age){
125 setName: function(name){
129 var myAnimal = new Animal(20);
130 myAnimal.setName('Micia');
131 alert(myAnimal.name); // alerts 'Micia'
133 [document.id]: /core/Element/Element#Window:document-id