640
Working with External Data
■
You don’t 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 can’t
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.
NO
TE
You must have ColdFusion installed on your web server for this example.
Содержание FLASH 8-LEARNING ACTIONSCRIPT 2.0 IN FLASH
Страница 1: ...Learning ActionScript 2 0 in Flash...
Страница 8: ...8 Contents...
Страница 18: ...18 Introduction...
Страница 30: ...30 What s New in Flash 8 ActionScript...
Страница 66: ...66 Writing and Editing ActionScript 2 0...
Страница 328: ...328 Interfaces...
Страница 350: ...350 Handling Events...
Страница 590: ...590 Creating Interaction with ActionScript...
Страница 710: ...710 Understanding Security...
Страница 730: ...730 Debugging Applications...
Страница 780: ...780 Deprecated Flash 4 operators...
Страница 830: ...830 Index...