What is Data Binding?


You may often hear the term data binding associated with discussions of Flash components. Data binding is the process of taking information and adding it to a component, to display the information or to manipulate the data in a meaningful way. Any information that you bind to a component is often called a data provider. Data providers can be very simple, such as a String value (for example, a heading at the top of a movie with the text "Welcome to the Site"), or very complicated, such as a RecordSet object or an Array value (for example, a list of employees in your company, complete with first and last names, identification numbers, photo URLs, and so on). In Flash movies, you can take a data provider and bind it to a component in one of four ways:

  • Adding data in the Parameters tab: As you learned in the last chapter, you can add data to a component instance by changing values in the Parameters tab of the Property inspector or the Component Inspector panel. While this approach is easy to understand and implement, the data used with the component is static — for most Flash applications you build, you will want to employ more dynamic methods of assigning data to components.

  • Visual data binding: If you're using Flash Pro 8, you can use the Bindings and Schema tabs of the Component Inspector panel to link data and events between Data and User Interface components in your Flash movie. This approach does not require much (if any) ActionScript code for you to type yourself. When you use the Bindings and Schema tabs to link components, the DataBindingClasses symbol is automatically added to your movie's library. You don't need to do anything with this symbol in your own code — Flash 8 takes care of just about everything behind the scenes.

  • Custom data provider code: You can write your own ActionScript to create data and bind the data to one or more components. This approach can use Data components to load external data, or you can build your own data handling objects that pass data to components within the movie.

  • DataBindingClasses in ActionScript: You can use the same DataBindingClasses symbol that is included with your Flash movie for visual data binding in your own ActionScript code. This method is by far one of the most complex ways to link data and events between Flash components.

In this chapter, you learn how to use visual data binding and custom data provider code to bind data with components.




Macromedia Flash 8 Bible
Macromedia Flash8 Bible
ISBN: 0471746762
EAN: 2147483647
Year: 2006
Pages: 395

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net