Monday, February 15, 2010

tricky!




I had some getters and setters in Actionscript that were accessing a private member variable _status, which looked like:


private var _status:String;

// Getters and setters for status
public function get status():String {
return _status;
}

[Bindable(event="statusChanged")]
public function set status(value:String):void {
_status = value;
statusChanged = true;
invalidateProperties();
dispatchEvent(new StatusChangeEvent(value));
}


I couldn't figure out how to call the setter function from Actionscript, and looked all over. Turns out the solution is way easier than I imagined, just set the "status" variable:


status = STATUS_BUSY;


This calls the appropriate setter.