LoadVars

Object 
    | 
    +-LoadVars 
 
public dynamic class LoadVars 
extends Object

The LoadVars class is an alternative to the loadVariables() function for transferring variables between a Flash Lite and a web server over HTTP. Use the LoadVars class to obtain verification of successful data loading and to monitor download progress.

The LoadVars class lets you send all the variables in an object to a specified URL and load all the variables at a specified URL into an object. It also lets you send specific variables, rather than all the variables, which can make your application more efficient. Use the LoadVars.onLoad handler to ensure that your application runs when data is loaded, and not before.

The LoadVars class works much like the XML class; it uses the methods load(), send(), and sendAndLoad() to communicate with a server. The main difference between the LoadVars class and the XML class is that LoadVars transfers ActionScript name and value pairs, rather than an XML DOM tree stored in the XML object. The LoadVars class follows the same security restrictions as the XML class.

Availability

Flash Lite 2.0

Property summary

Modifiers

Property

Description

 

contentType:String

The MIME type that is sent to the server when you call LoadVars.send() or LoadVars.sendAndLoad().

 

loaded:Boolean

A Boolean value that indicates whether a load or sendAndLoad operation has completed, undefined by default.

Properties inherited from class Object

Event summary

Event

Description

onData = function(src:String) {}

Invoked when data has completely downloaded from the server or when an error occurs while data is downloading from a server.

onLoad = function(success:Boolean) {}

Invoked when a LoadVars.load() or LoadVars.sendAndLoad() operation has ended.

Constructor summary

Signature

Description

LoadVars()

Creates a LoadVars object.

Method summary

Modifiers

Signature

Description

 

addRequestHeader(header:Object, headerValue:String) : Void

Adds or changes HTTP request headers (such as Content-Type or SOAPAction) sent with POST actions.

 

decode(queryString:String) : Void

Converts the variable string to properties of the specified LoadVars object.

 

getBytesLoaded() : Number

Returns the number of bytes downloaded by LoadVars.load() or LoadVars.sendAndLoad().

 

getBytesTotal() : Number

Returns the total number of bytes downloaded by LoadVars.load() or LoadVars.sendAndLoad().

 

load(url:String) : Boolean

Downloads variables from the specified URL, parses the variable data, and places the resulting variables into the LoadVars object.

 

send(url:String, target:String, [method:String]) : Boolean

Sends the variables in the LoadVars object to the specified URL.

 

sendAndLoad(url:String, target:Object, [method:String]) : Boolean

Posts variables in the LoadVars object to the specified URL.

 

toString() : String

Returns a string containing all enumerable variables in the LoadVars object, in the MIME content encoding application/x-www-form-urlencoded.

Methods inherited from class Object