O'Reilly logo

Flash 8 Cookbook by Joey Lott

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Chapter 19. Using Data

There was a time when Flash was used exclusively for timeline-based animations. However, many current Flash applications—even simple ones—load and send data to and from external resources. For example, a simple web site built in Flash might display news. In order to keep the news fresh, it’s important to be able to load the text from an external resource, such as a text file or from a PHP page that retrieves the data from a database. If you have a comments form, you’ll need to send data to a script. There are many potential uses of such data in Flash applications.

To work with data most effectively, you’ll need to use ActionScript. In a few cases, the ActionScript will be relatively simple. For example, if you want to load variables from an external resource, the solution involves ActionScript as discussed in Recipe 19.1. However, there are also mechanisms for working with data in basic ways that do not require ActionScript. In this chapter, you’ll read about solutions that use simple and/or minimal ActionScript. Non-ActionScript solutions are discussed where appropriate.

19.1. Loading Variables

Problem

You want to load variables at runtime.

Solution

Use a LoadVars object. Call the load( ) method.

Discussion

There are many reasons you might want to load variables at runtime. Loading variables at runtime makes applications more dynamic than they would be if you had to hardcode all values into the file. For example, if your application displays a new quote or snippet ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required