The LoadVars object offers a cleaner, easier way to carry out the task of exchanging data with a server. Adi Reddy Mora explains how this object, introduced in Flash Player 6, can help you to more easily transfer variables between a Flash movie and a server.
The Power of LoadVars Object - Receiving the variables in server-side script (Page 3 of 5 )
You can access the flash variables in the server-side script normally, in the same way you access form POST/GET variables. The variable names will be the names you use when associating the variables to the LoadVars Object.
Example 1 (ASP): Request(“ type”);
Example 2 (PHP): $_POST['type']
Example 3 (ColdFusion): #FORM. type#
Sending variables back to flash from server:
You can also send variables back to flash from the server. You just need to print the data on the server-side page for flash to read that data in the following format:
&name=John&id=342&ecode=e123
In the above string name, id and ecode are the variable names that can be used in flash to read the data. You can pass as many variables as you require by seperating them with ampersand (&) symbol.
Example 1 (ASP):
You can use Response object to write the data in ASP
Response.Write("&name=John&id=342&ecode=e123")
Eample 2 (PHP):
You can use print or echo language constructs to write data in PHP.
echo "&name=John&id=342&ecode=e123";
Eample 3 (ColdFusion):
You can use <cfoutput> tag to output data to flash.
<cfoutput>&name=John&id=342&ecode=e123</cfoutput>
The LoadVars class consists of three methods for communicating with the server.
LoadVars.load
LoadVars.send
LoadVars.sendAndLoad
We have seen the usage of LoadVars.sendAndLoad method for sending and receiving data to and fro from the server.
Similarly, based on your requirements, if you want to only receive the data from the server, you can use LoadVars.load method with the parameter URL to load data from the server.
LoadVars.load("asp_net_php_page");
If you want to only send data to the server you can use the LoadVars.send method.