Search code examples
actionscriptactionscript-2loadvars

loadVariables() and LoadVars


I am currently developing an Flash Movie which sends a simple POST request with a few parameters to a PHP URL. The only problem is that I am not sure which of two (loadVariables & LoadVars) methods I should use. What are the pros and cons?


Solution

  • LoadVars Class:

    The LoadVars class is an alternative to the loadVariables() function for transferring variables between a Flash Lite and a web server over HTTP. Use the LoadVars class to obtain verification of successful data loading and to monitor download progress.

    The LoadVars class lets you send all the variables in an object to a specified URL and load all the variables at a specified URL into an object. It also lets you send specific variables, rather than all the variables, which can make your application more efficient. Use the LoadVars.onLoad handler to ensure that your application runs when data is loaded, and not before.

    The LoadVars class works much like the XML class; it uses the methods load(), send(), and sendAndLoad() to communicate with a server. The main difference between the LoadVars class and the XML class is that LoadVars transfers ActionScript name and value pairs, rather than an XML DOM tree stored in the XML object. The LoadVars class follows the same security restrictions as the XML class.

    - Copied verbatim from Adobe Flash Platform - LoadVars

    loadVariables Function:

    Reads data from an external file, such as a text file or text generated by ColdFusion, a CGI script, Active Server Pages (ASP), PHP, or Perl script, and sets the values for variables in a target movie clip. This action can also be used to update variables in the active SWF file with new values.

    The text at the specified URL must 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. For example, the following phrase defines several variables:

    company=Macromedia&address=600+Townsend&city=San+Francisco&zip=94103
    

    - Copied verbatim from Adobe Flash Platform - loadVariables Function