Chapter 19. Sending and Loading Data

Introduction

There are many reasons why you may want to send and load values from and to your Flash movies, including to:

  • Send form values to a server-side script to store in a database.

  • Send values from an email form to a server-side script to send the email.

  • Load values from a text file (appropriate when the values are subject to change, such as for the current weather or for a links page).

  • Load values from a server-side script where the values are drawn from a database, such as categories in an e-commerce application.

  • Send values to a server-side script for processing, and return a value to the Flash movie, such as for a login process.

When loading data from a URL, the Flash Player interprets the data in one of three possible ways: as text, raw binary data, or URL-encoded variables. URL-encoded variables follow these rules:

  • Each variable name is associated with a value using an equals sign, without spaces on either side of the equals sign.

  • Variable values loaded into Flash movies are always treated as strings; therefore, you should not enclose any values in quotes, as you would within ActionScript. A proper example of this is artist=Picasso.

  • When there is more than one name/value pair, each pair is separated by an ampersand—for example, artist=Picasso&type=painting.

  • Spaces within the values should be replaced by plus signs (+), not %20, as in: title=The+Old+Guitarist. (Spaces and %20 may also work, but stick with plus signs for the greatest compatibility.) ...

Get ActionScript 3.0 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.