Hi Joseph, thanks for the reply - no, the provided example was nothing more than a scenario off the top of my head, and probably not a great one, so I'm not looking for a formatter.
What I'm looking for is the best way to trigger a method whenever a bindable value changes. Changewatcher achieves what I want to do here, and so does BindSetter to a lesser degree (where the destination is essentially a method ... but that seems to be stretching its intended use). ChangeWatcher seems to be the correct solution here - I just wanted to ensure I wasn't missing anything as I was intending to blog about it. Cheers for the reply though, much appreciated :) On Wed, Jun 25, 2008 at 5:58 AM, Joseph Balderson <[EMAIL PROTECTED]> wrote: > 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 > > > > > > > > > > > >