![]() ![]() ![]() | |
![]() | |
![]() | |
![]() |
You can use the LoadVars class instead of loadVariables()
to transfer variables between a SWF file and a server. 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. The response from the server triggers the LoadVars.onLoad()
method and sets variables in the target. You can use LoadVars to obtain error information and progress indications and to stream the data while it downloads.
The LoadVars class is similar to the XML class; it uses the methods load()
, send()
, and sendAndLoad()
to initiate communication with the 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 DOM (Document Object Model) tree stored in the XML object.
You must create a LoadVars object to call its methods. This object is a container to hold the loaded data.
The following procedure shows how to use a LoadVars object to load variables from a text file and display those variables in a text field.
day=11&month=July&year=2003
date_txt
.var dateVars = new LoadVars(); dateVars.onLoad = function(ok) { if (ok) { date_txt.text = dateVars.day+"/"+dateVars.month+"/"+dateVars.year; } }; dateVars.load("date.txt");
This code loads the variables in data.txt (day
, month
, year
), then formats and displays them in the text field date_txt
.
For more information, see LoadVars class.
![]() | |
![]() | |
![]() | |
![]() ![]() ![]() |