EasyManua.ls Logo

MACROMEDIA FLASH 8-LEARNING ACTIONSCRIPT 2.0 IN FLASH - Page 640

MACROMEDIA FLASH 8-LEARNING ACTIONSCRIPT 2.0 IN FLASH
830 pages
Print Icon
To Next Page IconTo Next Page
To Next Page IconTo Next Page
To Previous Page IconTo Previous Page
To Previous Page IconTo Previous Page
Loading...
640 Working with External Data
You dont need to create container movie clips for holding data or clutter existing movie
clips with variables specific to client/server communication.
The class interface is similar to that of the XML object, which provides some consistency
in ActionScript. It uses the methods
load(), send(), and sendAndLoad() to initiate
communication with a server. The main difference between the LoadVars and XML
classes is that the LoadVars data is a property of the LoadVars object rather than of an
XML Document Object Model (DOM) tree stored in the XML object.
The class interface is more straightforward—with methods named load, send,
sendAndLoad—than the older loadVariables interface.
You can get additional information about the communication, using the getBytesLoaded
and
getBytesTotal methods.
You can get progress information about the download of your data (although you cant
access the data until it is fully downloaded).
The callback interface is through ActionScript methods (onLoad) instead of the obsolete,
deprecated
onClipEvent (data) approach required for loadVariables.
There are error notifications.
You can add custom HTTP request headers.
You must create a LoadVars object to call its methods. This object is a container to hold the
loaded data.
The following procedure shows how to use ColdFusion and the LoadVars class to send an e-
mail from a SWF file.
To load data with the LoadVars object:
1. Create a CFM file in Macromedia Dreamweaver or in your favorite text editor. Add the
following text to the file:
<cfif StructKeyExists(Form, "emailTo")>
<cfmail to="#Form.emailTo#" from="#Form.emailFrom#"
subject="#Form.emailSubject#">#Form.emailBody#</cfmail>
&result=true
<cfelse>
&result=false
</cfif>
2.
Save the file as email.cfm, and upload it to your website.
3. In Flash, create a new document.
NOTE
You must have ColdFusion installed on your web server for this example.

Table of Contents

Related product manuals