LoadVars object

Availability

Flash Player 6.

Description

The LoadVars object is an alternative to the loadVariables() action for transferring variables between a Flash movie and a server.

You can use the LoadVars object to obtain verification of successful data loading, progress indications, and stream data while it downloads. The LoadVars object works much like the XML object; it uses the methods load(), send(), and sendAndLoad() to communicate with a server. The main difference between the LoadVars object and the XML object is that LoadVars transfers ActionScript name and value pairs, rather than an XML DOM tree stored in the XML object.

The LoadVars object follows the same security restrictions as the XML object.

You must use the constructor new LoadVars() to create an instance of the LoadVars object before calling its methods.

Method summary for the LoadVars object

Method Description
LoadVars.addRequestHeader() Adds or changes HTTP headers for POST operations.
LoadVars.getBytesLoaded() Returns the number of bytes loaded from a load() or sendAndLoad() method.
LoadVars.getBytesTotal() Returns the total number of bytes that will be downloaded by a load or sendAndLoad method.
LoadVars.load() Downloads variables from a specified URL.
LoadVars.send() Posts variables from a LoadVars object to a URL.
LoadVars.sendAndLoad() Posts variables from a LoadVars object to a URL and downloads the server's response to a target object.
LoadVars.toString() Returns a URL-encoded string that contains all the enumerable variables in the LoadVars object.

Property summary for the LoadVars object

All of the properties for the Key object are constants.

Property Description
LoadVars.contentType Indicates the MIME type of the data.
LoadVars.loaded A Boolean value that indicates whether a load or sendAndLoad operation has completed.

Event handler summary for the LoadVars object

Event handler Description
LoadVars.onLoad Invoked when a load or sendAndLoad operation has completed.

Constructor for the LoadVars object

Availability

Flash Player 6.

Usage

new LoadVars()

Parameters

None.

Returns

Nothing.

Description

Constructor; creates an instance of the LoadVars object. You can then use the methods of that LoadVars object to send and load data.

Example

The following example creates an instance of the LoadVars object called myLoadVars:

myLoadVars = new LoadVars();