MXML Implementation of ChangeWatcher
I often find myself needing a simple implementation of ChangeWatcher. I make a CreationComplete event handler for a component, create the ChangeWatcher, create a listener function, and do some simple action in the listener. I was thinking today that it would be nice if you could do all this in one line of mxml (like the mx:binding tag). So, I created the RPChangeWatcher which does just that.
I have to credit Brian Holmes for providing a really easy way to do non-visual components without extending UIComponent. This makes the RPChangeWatcher (thusly named to avoid namespace conflicts) really lightweight. Check out the sample application:
[kml_flashembed movie="http://www.rphelan.com/flex/MXMLChangeWatcher/MXMLChangeWatcher.swf" height="240" width="450" /]
This is a very simple example, but imagine you're using some form of MVC and the currentDP being a variable in your model. This particular view doesn't care how or why currentDP gets updated, it just wants to display an animation to transition between datasets. That isn't possible using regular data binding, but it's pretty clean and simple with an mxml ChangeWatcher.
I haven't experimented with this a lot yet, but given that you can use data binding on the host and chain properties, I can see some potential for some pretty advanced use cases.
Any thoughts?
About this entry
You’re currently reading “MXML Implementation of ChangeWatcher,” an entry by Ryan Phelan
- Published:
- 04.10.08 / 9am
- Category:
- Flex






6 Comments
Jump to comment form | comments rss [?] | trackback uri [?]