| |
|
||||
|
Custom Methods Our extends method automatically sandwiches a layer between Object.prototype and our top level class. What is the purpose of this? Well, judging by the name, customMethods, it would be a place to put custom functionality. This is what it does. These methods will be availabe to all classes and instance that use the system without the user having to insert them. This would be a good place for debugging tools for example, or extentions to Actionscript. Whatever the tool, all you have to do is insert it into the customMethod.prototype and it will be available. Note that putting things here will not pollute the way Object.prototype does, these methods (or properties if you like) will only be availabe to classes and instances in your system, not to other types of objects. Also, classMethod has no constructor (and it wouldn't run if it did) so it will not set values in the instance. It is for inheritance only. The sample download has an example of an custom method that traces the contents of each level in an object. It can be invoked from any instance by saying xxx.traceObject( ). It is very easy to add your own, give it a try! Just use the syntax: Object.customObject.prototype.xxx = function( ){ }
|