Chapter 7. USING DATA BINDING

Say your application knows someone’s display name (Jed90210) and you’d like to show that name in various places: on a button to sign out, on the person’s profile page, and on the welcome screen to say “hello.” You could just store a variable with the display name and reference that variable throughout the application. But what if that person decides to change their display name to Jed75961? In such a case, you’d need to write code to listen for changes to the display name, updating all references to it explicitly. If you’ve referenced the name in quite a few places, that would be a lot of code.

With Flex, you have another option. You can store the display name in one place and reference it all you want. If the display name were updated, all references to it would change automatically, without any need to write tedious code to listen for changes. You can accomplish all this through the magic of data binding.

What Is Data Binding?

Data binding is one of those features that makes Flex so great: it gives you the ability to easily pass information around. It is simply a way to reference a piece of data and watch for changes to that data in an intuitive way. This data can be anything from a piece of text, such as a display name, to a structured list of information, such as a bunch of stock quotes, and anything in-between—data is simply information, in any form. Essentially, data binding makes it natural for developers to share information across their applications. ...

Get Learning Flex 3 now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.