While working on a new site I've found a better way to load your data from text files or database. The new LoadVars Class gives much greater flexability.
From Macromedia site:
LoadVars.addRequestHeader()
Adds or changes HTTP headers for POST operations.
LoadVars.decode()
Converts a variable string to properties of the specified LoadVars object.
LoadVars.getBytesLoaded()
Returns the number of bytes downloaded by LoadVars.load() or LoadVars.sendAndLoad().
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.
Events
LoadVars.onData
Invoked when data has been completely downloaded from the server, or when an error occurs while data is downloading from a server.
LoadVars.onLoad
Invoked when a load or sendAndLoad operation has completed.code:
//what you do is create a object to store your vars
mystuff=new LoadVars()
//now we can create a funtion to handle the data when it's actually loaded
mystuff.onLoad=function(){
//assuming you have variables named variable1 and variable2
txt1.text=this.variableName //put the data into our editboxes.
txt2.text=this.variableName2
}
//to load the data
//Note:
//You must specify what LoadVar object the data loads into, doesn't have
//to be the same one.
mystuff.load("urltoPHPorTxtFile",mystuff,POST)
//to send data and load at the same time
first load the object with the data to send
mystuff.variable1=txt1.text;
mystuff.variable2=txt2.text;
//mystuff.sendAndLoad("urltoPHPorTxtFile",mystuff,PO ST)
As you can see there are many things this model allows over the old way.
- One you can send or load only or do both as with loadVariables.
- You can detect when the data is loaded and execute
- You can send only the data you want.


Reply With Quote