MACROMEDIA FLASH MX 2004-USING ACTIONSCRIPT IN FLASH Use Manual page 278

Using actionscript in flash
Hide thumbs Also See for FLASH MX 2004-USING ACTIONSCRIPT IN FLASH:
Table of Contents

Advertisement

For example, if you want to track the high scores for a game, you could store the scores on a server
and use
loadVariables()
The function call might look like the following example:
loadVariables("http://www.mySite.com/scripts/high_score.cfm", _root.scoreClip,
GET);
This example loads variables from the ColdFusion script called
clip instance
scoreClip
Any variables loaded with the
application/x-www-form-urlencoded (a standard format used by CFM and CGI scripts). The file
you specify in the
in this format so that Flash can read them.This file can specify any number of variables; variable
and value pairs must be separated with an ampersand (
separated with a plus (
highScore1=54000&playerName1=RGoulet&highScore2=53455&playerName2=
WNewton&highScore3=42885&playerName3=TJones
Note: You might need to URL-encode certain characters, such as the plus (+) or ampersand (&)
characters. For more information, see
url_encoding.htm.
For more information, see
,
getURL()
loadMovie()
Help.
Using the LoadVars class
If you are publishing to Flash Player 6 or later and want more flexibility than
offers, you can use the LoadVars class instead to transfer variables between a SWF file and a server.
The LoadVars class was introduced in Flash Player 6 to provide a cleaner, more object-oriented
interface for the common task of exchanging CGI data with a web server. Advantages of the
LoadVars class include the following:
You don't need to create container movie clips for holding data or clutter existing movie clips
with variables specific to client/server communication.
The class interface is similar to the XML object, which provides some consistency in
ActionScript. It uses the methods
communication with a server. The main difference between the LoadVars and XML classes is
that the LoadVars data is a property of the LoadVars object, rather than an XML Document
Object Model (DOM) tree stored in the XML object.
The class interface is more straightforward—with methods named
sendAndLoad
You can get additional information about the communication, using the
getBytesTotal
You can get progress information about the download of your data (although you can't access
the data until it is fully downloaded).
278
Chapter 11: Working with External Data
to load them into the SWF file each time someone played the game.
using the
GET
loadVariables()
parameter of
URL
loadVariables()
). For example, the following phrase defines several variables:
+
www.macromedia.com/support/flash/ts/documents/
"Using the LoadVars class" on page
, and the
LoadVars class
load()
—than the older loadVariables interface.
methods
HTTP method.
function must be in the standard MIME format
must write out the variable and value pairs
), and words within a value must be
&
entry in ActionScript Language Reference
,
, and
send()
sendAndLoad()
into the movie
high_score.cfm
278. Also, see
loadVariables()
loadVariables()
to initiate
,
,
load
send
getBytesLoaded
,
and

Advertisement

Table of Contents
loading
Need help?

Need help?

Do you have a question about the FLASH MX 2004-USING ACTIONSCRIPT IN FLASH and is the answer not in the manual?

Questions and answers

Subscribe to Our Youtube Channel

This manual is also suitable for:

Flash mx 2004 - actionscript

Table of Contents