Yes, they would go in the model (perhaps a presentation model) and be used
with binding like any other property,
eg.
currentState="{model.userState}"
There's also the Observe tag from Adobe consulting, but I hven't used it in
a while.
On Tue, May 19, 2009 at 4:12 PM, Steve Horvath
<[email protected]>wrote:
>
>
> Thanks! At least the first one looks like it should work for me. For the
> second one, I'm a little confused. Do those properties go into the model?
> How does the view watch for them and respond?
>
> ascii
>
>
> On Tue, May 19, 2009 at 8:10 AM, Richard Rodseth <[email protected]>wrote:
>
>>
>>
>> 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
>>>
>>>
>>
>
>