Home arrow Flash arrow Page 3 - The Power of LoadVars Object
FLASH

The Power of LoadVars Object


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.

Author Info:
By: Adi Reddy Mora
Rating: 4 stars4 stars4 stars4 stars4 stars / 31
February 09, 2005
TABLE OF CONTENTS:
  1. · The Power of LoadVars Object
  2. · Advantages of the LoadVars class
  3. · Receiving the variables in server-side script
  4. · Using LoadVars Object for loading data from text files
  5. · LoadVars.decode

print this article
SEARCH DEVARTICLES

TOOLS YOU CAN USE

advertisement
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.

LoadVars.load("asp_net_php_page", "_blank", "POST");


blog comments powered by Disqus
FLASH ARTICLES

- More Top Flash Game Tutorials
- Top Flash Game Tutorials
- Best Flash Photo Gallery Tutorials
- The Top Flash Tutorials for Menus
- 7 Great Flash Tutorials
- Adobe Creative Suite 5.5 Now Available
- Critical Flash Vulnerability Heats Up the Web
- More on Nonpersistent Client-Side Remote Sha...
- Nonpersistent Client-Side Remote Shared Obje...
- Using the Decorator Pattern for a Real Web S...
- Using Concrete Decorator Classes
- Delving More Deeply into the Decorator Patte...
- The Decorator Pattern in Action
- A Simple Decorator Pattern Example
- Decorator Pattern

Dev Articles Forums 
 RSS  Articles
 RSS  Forums
 RSS  All Feeds
Weekly Newsletter
 
Developer Updates  
Free Website Content 
Contact Us 
Site Map 
Privacy Policy 
Support 



© 2003-2012 by Developer Shed. All rights reserved. DS Cluster 1 - Follow our Sitemap
Popular Web Development Topics
All Web Development Tutorials