Flex Optimization Tip: Evaluate Your Setter Parameter

Flash Builder makes it easy to generate getters and setters from a variable definition. Just select the variable, right-click and choose Source > Generate getters/setters.

The generated code is simple; the getter returns the value and the setter sets the value:

private var _myData:String;

public function get myData():String {
    return _myData;

public function set myData(value:String):void {
   _myData = value;

Oftentimes in Flex, however, changing a variable is a trigger that causes other code to run or update. But why would you want this extra processing to occur if the value that is being assigned hasn’t changed?
Continue reading “Flex Optimization Tip: Evaluate Your Setter Parameter”