Home arrow Flash arrow Page 2 - Working with external data in Flash
FLASH

Working with external data in Flash


Because data for a website comes in many formats, it helps to have a variety of ways to handle this data. This article covers the different methods available in ActionScript for exchanging data.

Author Info:
By: Adi Reddy Mora
Rating: 4 stars4 stars4 stars4 stars4 stars / 26
May 11, 2005
TABLE OF CONTENTS:
  1. · Working with external data in Flash
  2. · getURL(), loadVariables(),loadVariablesNum(), loadMovie(), and loadMovieNum() methods
  3. · LoadVars Class
  4. · MovieClipLoader class
  5. · XML Class
  6. · XMLSocket Class

print this article
SEARCH DEVARTICLES

TOOLS YOU CAN USE

advertisement
Working with external data in Flash - getURL(), loadVariables(),loadVariablesNum(), loadMovie(), and loadMovieNum() methods
(Page 2 of 6 )

The methods listed as the title of this section use the HTTP or HTTPS protocol to send information in URL-encoded format.

getURL(): This method loads a document from a specific URL into a window or passes variables to another application at a defined URL. This method can used when you want to load a different URL onto the existing one. You also have the option of passing the data to a different URL using http POST and GET methods.

Example:

//opens
http://www.devarticles.comin a blank window
getURL("http://www.devarticles.com", "_blank");
//sends the variables from flash to
http://www.devarticles.com
using POST method
getURL("http://www.devarticles.com", "_blank", ”POST”); 

loadVariables() , loadVariablesNum():These methods reads data from any external file, such as a text file or text generated by any server-side scripting technology such as ColdFusion, CGI script, ASP, PHP, Perl, and so on, and set the values for variables in a Flash.

The main difference between the loadVariables() method and the loadVariablesNum() method is that loadVariables() sets the values for variables in a target movie clip, while loadVariablesNum() sets the values for variables in a level. You can also use this method to update variables in the active SWF file with new values.

The text in the text files, or the text generated by the server-side script, should be in the standard MIME format application/x-www-form-urlencoded (a standard format used by CGI scripts). Any number of variables can be specified, as in the string shown below.

name=Jhon&age=22&zip=534235
Example:
// Variables from data.txt will be loaded into target_mc movie clip
loadVariables("data.txt", target_mc);
// Variables from data.txt will be loaded into level 1
loadVariablesNum("data.txt", 1);

You can also use the movie clip’s loadVariables() method to load data directly into the movie clip.

Ex: target_mc. loadVariables ("data.txt");

 

loadMovie() , loadMovieNum(): These methods let you load external SWF files and JPEG files into the existing SWF file and are similar to loadVariables() and loadVariablesNum() methods. The difference between loadMovie() and loadMovieNum() is also the same, target and level.

Example:

// Loads play.swf file into target_mc movie clip

loadMovie("play.swf", target_mc);

// Loads play.jpg image into level 1

loadMovieNum("play.jpg", 1);

You can also use the movie clip’s loadMovie() method to load external SWF files or JPEG images into the movie clip directly.

Ex: target_mc.loadMovie("play.jpg");


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