A couple of techniques to be aware of:
1) Binding functions
currentState="{computeState(model.username)}"
(computeState is in the Script block of your MXML and will fire when any of
the argument expressions change)
2) Computed properties with custom getters/setters:
[Bindable(event="userStateChanged")]
public function get userState():String {
// return something based on user name
}
[Bindable(event="userNameChanged")]
public function get userName():String {
return _userName;
}
public function set userName(value:String):void {
_userName = value; // Should really check that it's different
dispatchEvent(new Event("userNameChanged"));
dispatchEvent(new Event("userStateChanged"));
}
On Tue, May 19, 2009 at 12:10 AM, steve horvath <[email protected]
> wrote:
>
>
> I have a view that I would like to change state when a field in my model
> changes values. Up until now I've been using data binding to link my view
> and model. It seems like my current situation I will have to dispatch an
> event from the model and have the view watch it.
>
> In the model:
> A username string that changes occasionally and is sometimes null.
>
> In the view:
> A List - should become unselected if the username becomes null.
> A State - should change when the username changes values.
>
> Do I need to register an event handler in my view? Can I do this somehow
> through data binding? Or is there another way?
>
> ascii
>
>
>