19.9. Sending Data Using Data Binding

Problem

You want to send data to the server when making a service call, but you don’t want to have to write much ActionScript.

Solution

Use data binding to send data from components to the service.

Discussion

In Recipe 19.7, you learned how to use data binding to display data that is returned from a connector component call. You can also use data binding to determine what values to send to a service via a connector component. For example, a web service method may require a parameter. You can use data binding to tell Flash to retrieve the value for that parameter from a component.

The majority of data binding is the same regardless of whether you’re displaying returned data or sending data from components. Refer to Recipe 19.7 for details on data-binding basics. When you are sending data as parameters via data binding, you’ll want to add bindings from component properties to the connector component’s params field or fields nested under the params field. There are a few additional considerations, discussed in this recipe.

When you are sending data as parameters, you most frequently won’t need to format or encode the data. For example, if you allow the user to select a book from a list of books in a combo box and then send that to a Flash Remoting service as a parameter, you may not need to encode or format that data. Likewise, if you want to send a date parameter from a DateChooser or DateField component, you won’t need to encode or format that value. ...

Get Flash 8 Cookbook 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.