It seems like you are misunderstanding the use of binding, which is to "tie" 
the 
value of one property to another with loose coupling such that when one changes 
(i.e. the source), the other (i.e. the destination) reflects that value change 
precisely.

It sounds like what you're looking for is a custom Formatter, able to take an 
input and interpret it based on an algorithm, and that formatter value can be 
bound to a destination property, which in your case seems to be the 
currentState 
of the application. If an algorithm will not suite your purposes, I would 
recommend you stick with the switch statement inside a manager class.

If the user level and application state are so closely tied, why not just name 
your application state strings according to the user level strings. If some 
sort 
of validation and logic needs to happen beforehand, then what you're probably 
looking after is a manager class to make those decisions.

_______________________________________________________________

Joseph Balderson, Flash Platform Developer | http://joeflash.ca


nwebb wrote:
> Hi,
> 
> I was looking at how you can trigger a function when an argument is a 
> bindable value....
> 
> e.g.
> 
> //userLevel is a bindable value & formatMessage is a function will be 
> called when userLevel changes
> <mx:Label text="{formatMessage(userLevel)}" />
> 
> This is cool if you're just displaying a value in a text field. However, 
> what if you don't necessarily want to return a value (i.e. you don't 
> have a destination)?
> Hopefully this will show what I mean:
> 
> private function stateManager(value:String):void
> {
>      switch(value)
>      {
>         case "basic":
>              currentState = '';
>              break;
>          case "admin":
>               currentState = 'AdminState';
>               break;
>          default:
>               currentState = '';
>       }
>  }
> 
> BindingUtils methods and the binding tag both expect a destination, but 
> in this case there isn't one. Is the solution simply to use 
> ChangeWatcher instead, or can this be done using binding syntax?
> 
> Cheers
> 
> 
> 
> 
> 

Reply via email to