
oop
Get flash to fully experience Pearltrees
JavaScript Method Overloading
In a side project that I’ve been working on I built a quick-and-dirty function for doing simple method overloading. For those of you who aren’t familiar with, it’s just a way of mapping a single function call to multiple functions based upon the arguments they accept. Here’s the function in question: // addMethod - By John Resig (MIT Licensed) function addMethod ( object , name , fn ) { var old = object [ name ] ; object [ name ] = function ( ) { if ( fn. length == arguments. length ) return fn. apply ( this , arguments ) ; else if ( typeof old == 'function' ) return old. apply ( this , arguments ) ; } ; } and here is how you might use it: function Users ( ) { addMethod ( this , "find" , function ( ) { // Find all users... } ) ; addMethod ( this , "find" , function ( name ) { // Find a user by name } ) ; addMethod ( this , "find" , function ( first , last ) { // Find a user by first and last name } ) ; }Using the compact extend function to simulate class-based inheritance in JavaScript we have many of the same features of Ruby classes. One important feature is that classes remain open and that changes in the superclass are automatically also in the subclass. Through the extend function's natural chaining of prototypes we can have this open and inheritable changes.
Ruby's Open Classes and Inheritance in JavaScript
darron schall :: Multiple Inheritance in ActionScript 3
ActionScript 2.0 OOP by senocular Welcome Here we are going to cover Object Oriented Programming (OOP) in Flash 7 with ActionScript 2.0, a new form of ActionScript introduced in Flash MX 2004. With any luck you've already gone through the sections covering OOP with ActionScript 1.0 . Much of the following will be based off of that foundation, though it is not all necessary to know in order to continue. Here is an outline of all the sections covered.

