Accessibility

Table of Contents

Data for Designers: Connecting to Data in Flash Using Data Wizards

Understanding the Data Connection Wizard

The Data Connection wizard and DataGrid Column Editor were created to make developing in Flash easier for designers. Being able to interface quickly with dynamic data without using much ActionScript helps Flash users who are either new to code or don't like to write it and yet who have to meet the need for more interactive or data-rich files. The Data Connection wizard allows you to connect to web services or XML data sources at runtime and return records of data to SWF files.

Use the Data Connection wizard when you want to work with an array of data that's returned to the movie. An array is any number of specifically arranged items, such as a series of daily forecasts or the names and statistics of players on a baseball team. The Data Connection wizard must display more than one record of data in an array. The data is stored in the DataSet component and you control how to display the data in the SWF file. The complex DataSet component is not terribly easy to work with without the wizard; not only does it organize data, but it sorts, filters, and modifies data as well.

By default, the Data Connection wizard connects and consumes the data feed and organizes it in a DataGrid component instance. The DataGrid is similar to a spreadsheet with columns and rows that contain information; you bind (connect) the data that you import to the DataGrid. Data doesn't need to be placed in a DataGrid component; you can choose to bind the data to other components and trigger it in other ways (you'll find out one way in the first example). However, you will have to construct those bindings in Flash yourself if you choose to use components other than DataGrid. You can find information on how to bind data in the Flash documentation.

What the Wizard Isn't Meant For

The Data Connection wizard isn't meant for connecting to all web services and XML data, or for all kinds of projects that incorporate them. You shouldn't use the wizard if you only want to work with a couple fields of data that are returned to Flash because an array is required. Also, the wizard does not allow you to use nested arrays, which is a complex data structure incorporating an array of data inside another array. Remember that it is possible to use this data with Flash because you can use nested arrays in the Bindings tab of the Component Inspector panel.

After spending the better part of a day playing with the new wizard and trying to consume various web services on xmethods.com, I found that well over half of the web services I tried worked using the Data Connection wizard, but the others did not. Although there were some methods I could consume using the WebServiceConnector component, these same methods didn't always work with the new Data Connection wizard. In my experience, web services that did work with the wizard worked very well. It was dead simple to define a new web service using the Web Services panel and then run through the wizard and make a fully populated DataGrid component work in a SWF file without writing a single line of code.

Summing Up the Wizard

The Data Connection wizard isn't revolutionary in the world of Flash but it simplifies connecting to sources of external data. Flash MX Professional already consumes and uses XML and web service data using the data connector components, and both versions use ActionScript and classes found in the common libraries. Therefore, the Data Connection wizard doesn't do anything that Flash can't already do, and at times the wizard is not able to use or handle the data that the Web Service classes and some ActionScript is able to accomplish. However, the wizard can be very useful for prototyping features quickly, or if you quickly want to syndicate some content from an external web service or XML file into your Flash movie. Be forewarned, however: This wizard won't necessarily work with every web service out there.