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;
}
}
Related examples in the same category