• Create BookmarkCreate Bookmark
  • Create Note or TagCreate Note or Tag
  • PrintPrint

External Data Files

You’ve seen how to store text files containing ActionScript in external files and how to set initial values for variables through HTML. In both cases, however, after the movie starts to play, no data from the outside world is received. (Actually, in the case of external scripts, once you export the movie, nothing comes into your movie). In the next technique, you’ll learn how to store data in external files that aren’t loaded until you request them at runtime. Specifically, your script can invoke Flash’s loadVariables() method at any time to load variables from an external text file (or another data source, as you’ll see in the “Server Scripts” section later in this chapter). By loading variables from a file at runtime, a Flash movie reflects the current values found in the file.

There are several ways to load variables. Naturally, I’ll recommend the new “Flash MX way”—the LoadVars object. However I want to point out the other two ways you can do load variables: as a function and as a method of a Movie Clip. Although this may sound like a case of “see how hard it used to be,” I’m mentioning the old ways for two reasons: the LoadVars object only works in the Flash 6 player and—perhaps more importantly—because all three syntaxes look similar you should be able to recognize the difference.


PREVIEW

                                                                          

Not a subscriber?

Start A Free Trial


  
  • Creative Edge
  • Create BookmarkCreate Bookmark
  • Create Note or TagCreate Note or Tag
  • PrintPrint