22.9. Accessing External Data
Problem
You want to load external data into a Flash Lite movie.
Solution
Utilize the loadVariables( ) function in conjunction with a server-side script.
Discussion
One of the exciting features of the Flash Lite 1.1 player is its ability to access dynamic data via the Internet. You can develop Flash Lite movies that incorporate frequently changing data, such as sports scores, movie times or weather conditions. Though this technique is not appropriate for all applications, the bulk of the most popular Flash Lite applications incorporate some amount of dynamic data.
The ActionScript function loadVariables( ) is used to achieve this goal. loadVariables( ) sends a request to a specified URL, and loads the returned data into a specified movie clip as ActionScript variables that you can then reference in your movie.
Flash Lite expects the data returned via a loadVariables( ) call to be in a special format called URL-encoded text. Alphanumeric characters do not require special formatting; however, most punctuation and whitespace characters do. As an example, a single-space character is converted to a plus sign (+) in URL-encoded text.
Conveniently, all server-side scripting languages (ColdFusion, PHP, ASP, and so on) have built-in functions to format the text for you. For this example, I will use PHP to pass the current month, day, and year to a Flash Lite movie. The Flash Lite movie will display this information in a dynamic text field on the stage. The first step ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access