Dynamically Adding New Behavior to an Instance : Dynamic object : Class Flash / Flex / ActionScript examples


Flash / Flex / ActionScript examples » Class » Dynamic object »

 

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(  ));

        
    }
  }
}

        



Leave a Comment / Note


 
Verification is used to prevent unwanted posts (spam). .


Flash / Flex / ActionScript examples

 Navioo Class
» Dynamic object