Hi Nick,

As long as you define the [Bindable] metadata tag right before a getter, the 
order of the setters/getters doesn't really matter.

However, as a coding convention, most people do define getters before setters, 
it helps by making your code more maintainable.

Here are a few examples where the order does matter:

/*~~~~~~THIS IS CORRECT~~~~~~~~~~~~~~*/

[Bindable("fooChanged")]
public function get foo():String{
    return _bar;
}
public function set foo(value:String):void{
    _bar=value;
    this.dispatchEvent(new Event("fooChanged"));
}
private var _bar:String;

/////////////////////////////////////////////////


/*~~~~~~THIS IS STILL CORRECT even through the setter is defined 
first~~~~~~~~~~~~~~~~~~~~~~~~*/

public function set foo(value:String):void{
    _bar=value;
    this.dispatchEvent(new Event("fooChanged"));
}
[Bindable("fooChanged")]
public function get foo():String{
    return _bar;
}
private var _bar:String;

/////////////////////////////////////////////////


/*~~~~~~THIS IS INCORRECT~~~~~~~~~~~~~~~~~~~~~~~~*/

[Bindable("fooChanged")]
public function set foo(value:String):void{
    _bar=value;
    this.dispatchEvent(new Event("fooChanged"));
}
public function get foo():String{
    return _bar;
}
private var _bar:String;

/////////////////////////////////////////////////


Hope this helps clear things up,

Tibor.

www.tiborballai.com

--- In [email protected], Nick Middleweek <n...@...> wrote:
>
> Hi,
> 
> I've been told to put my getters before my setters when defining Interfaces
> and creating the Class functions...
> 
> ... then Bind my getters.
> 
> 
> Is this a known practice? Any what's the benefit? Is it something to do with
> how Flex calls the getters when setting via the setters?
> 
> 
> 
> Thanks,
> Nick
>


Reply via email to