Archive for May, 2011|Monthly archive page

FDT 4 – How to auto-generate Getters and Setters

Again, this is common knowledge but I thought I would post it for convenience and the hope that it will help someone else out in the future.

To generate a getter and/or a setter create a variable in the declaration section of your class. Make sure to prefix it with an underscore _ and also make it private. Simply put the cursor in the variable and press Cmd-1 (on a Mac). FDT will then generate the statements for you. For instance, in the below statement, if I put the cursor on the _alertText_str variable here:-

private var _alertText_str:String;

And press Cmd-1, FDT will generate:-

public function get alertText_str() : String {
return _alertText_str;
public function set alertText_str(alertText_str : String) : void {
_alertText_str = alertText_str;

Thanks to @dougal07 for showing me this.