Dynamically Adding New Behavior to an Instance
package{
import flash.display.Sprite;
public class Main extends Sprite{
public function Main(){
var info:Object = new Object( );
info.city = "Toronto";
info.country = "Canada";
info.getAddress = function ( ):String {
return this.city + ", " + this.country;
}
trace(info.getAddress( ));
}
}
}
Related examples in the same category