Declare a constructor method for the Example class : Constructor : Class Flash / Flex / ActionScript examples


Flash / Flex / ActionScript examples » Class » Constructor »

 

Declare a constructor method for the Example class


 

package{
  import flash.display.Sprite;
  
  public class Main extends Sprite{
    public function Main(){

        var example:Example = new Example(  );
        trace(example.getId(  ))// Displays: Example Class
    }
  }
}
class Example {
        private var _id:String;
        public function Example(  ) {
            _id = "Example Class";
        }
        public function getId(  ):String {
            return _id;
        }
    }

        



Leave a Comment / Note


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


Flash / Flex / ActionScript examples

 Navioo Class
» Constructor