Home arrow Flash arrow Page 5 - 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 - LoadVars.decode
(Page 5 of 5 )

This method can be used to internally decode name/value pairs into object properties and values. It accepts one argument as a string that contains name/value pairs and the string will be converted into object properties and associated values.

Name/value pairs look like the following:
myvariable=value&myothervariable=anothervalue

 

This hidden method will convert the above name/value pairs into two properties "myvariable" and "myothervariable." The values of these properties are the associated values in the name/value pair string, so the value of "myvariable" in the above string is "value" and the value of "myothervariable" in the above string is "anothervalue." Here's a little code example to show you what this method does:

// create a new instance of the LoadVars object
vat lv:LoadVars = new LoadVars();

// call the method with name/value pair string
lv.decode("name=Jhon&age=22");

 

// iterate over all the properties in the ‘lv’ object
for(var i in lv){
    //trace the property name and property value
    trace(i+":"+ lv [i])
}


The output of the above code will be:

name:Jhon
age:22

 

Conclusion

 

The LoadVars Object is the powerful way to obtain simple communication with any server or fo loading data from text files. However, for complex data communication it is recommended to use WebService Connector component available in Flash MX 2004 Professional, or you can also use Flash Remoting MX for an effective and efficient method of communicatio. Flash Remoting MX uses Action Message Format (AMF), a binary message format designed for the ActionScript object model, which was modeled on the Simple Object Access Protocol (SOAP).AMF uses a packed format to relay information so the communication with the server will be efficient.


DISCLAIMER: The content provided in this article is not warranted or guaranteed by Developer Shed, Inc. The content provided is intended for entertainment and/or educational purposes in order to introduce to the reader key ideas, concepts, and/or product reviews. As such it is incumbent upon the reader to employ real-world tactics for security and implementation of best practices. We are not liable for any negative consequences that may result from implementing any information covered in our articles or tutorials. If this is a hardware review, it is not recommended to open and/or modify your hardware.

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 3 - Follow our Sitemap
Popular Web Development Topics
All Web Development Tutorials