The new Flex 4 states syntax: more than meets the eye
If you have played around with the new Flex 4 states then you know just how easy it is to change the visual appearance of a component. But the <states> syntax also works on events. So now we can do something like this:
<s:states> <s:State name="disarry" /> <s:State name="confusion" /> <s:State name="mind" /> </s:states> <s:Button click.disarry="onClick_disarry()" click.confusion="onClick( 'confusion' )" click.mind="onClick( 'whatever' )"/>
Of course you could just call to the same event handler and run a switch on the currentState. That would do the same but this approach seems a little cleaner.
You can also change things like the skinClass of a component on a state change. Actually, I can’t think of anything that doesn’t apply to the new states syntax. It’s just going to take some time getting used to and thinking about how this will affect our code organization. I’m pretty sure this will help keep simplify things and make for cleaner and more easily maintained code.
And yes, I could totally see myself making <states> that have the names above. I give things weird names. I’m pretty sure that when a developer goes to hell their punishment is to maintain my code. :)
If something here has proved valuable to you then feel free to drop a couple of bucks in the tip-jar.






