Thursday, December 17, 2009

Manual Data Binding in Flex

You need to set up data binding manually. This allows you to do much more complicated and powerful things with data binding

Typically, you set up data binding using the simple Flex data binding syntax, like this:

Assuming the property is bindable, this will automatically change the label every time the "someProperty" property changes.But what if you want to do something more complicated, like execute a block of code in response to a property changing? You can't use the simple Flex data binding syntax. Rather, you have to set data binding up manually which you can do with the mx.binding.utils.ChangeWatcher class like this:
ChangeWatcher.watch(someObject, "someProperty", onPropertyChange);
This will ensure that your onPropertyChange function will get called every time the "someProperty" property changes.This is especially useful and powerful when using the Cairngorm Flex framework.

No comments:

Freelance