Define a class : Class « Class « Flash / Flex / ActionScript






Define a class

 

package{
  import flash.display.Sprite;
  
  public class Main extends Sprite{
    public function Main(){
        var crTest:Car = new Car();
        trace(crTest.make);  // Displays: undefined
        crTest.make = "Old";
        trace(crTest.make);  // Displays: Olds


    }
  }
}
class Car {
  private var _sMake:String;

  public function get make():String {
    return _sMake;
  }

  public function set make(sMake:String):void {
    _sMake = sMake;
  }
}

        








Related examples in the same category

1.Define class with properties
2.Class Objects
3.Convert class to the more general type without writing any explicit code.