•
The callback interface is through ActionScript methods (
deprecated
onClipEvent
•
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.
Note: You must have ColdFusion installed on your web server for this example.
To load data with the LoadVars object:
Create a CFM file in Macromedia Dreamweaver or in your favorite text editor. Add the
1.
following text to the file:
<cfif IsDefined("Form")>
<cfmail to="#Form.emailTo#" from="#Form.emailFrom#"
subject="#Form.emailSubject#">#Form.emailBody#</cfmail>
&result=true
<cfelse>
&result=false
</cfif>
Save the file as email.cfm, and upload it to your website.
2.
In Flash, create a new document.
3.
Create four input text fields on the Stage, and give them the following instance names:
4.
,
emailFrom_txt
emailTo_txt
Create a dynamic text field on the Stage with the instance name
5.
Drag a PushButton component instance to the Stage, and give it the instance name
6.
.
submit_btn
Select Frame 1 in the Timeline, and open the Actions panel (Window > Development Panels >
7.
Actions) if it isn't already open.
Enter the following code in the Actions panel:
8.
this.submit_btn.onRelease = function() {
var emailResponse:LoadVars = new LoadVars();
var email:LoadVars = new LoadVars();
email.emailFrom = emailFrom_txt.text;
email.emailTo = emailTo_txt.text;
email.emailSubject = emailSubject_txt.text;
email.emailBody = emailBody_txt.text;
email.sendAndLoad("http://www.yoursite.com/email.cfm", emailResponse,
"POST");
emailResponse.onLoad = function() {
debug_txt.text = this.result;
};
};
(data) approach required for loadVariables.
,
emailSubject_txt
Sending and loading variables to and from a remote source
) instead of the obsolete,
onLoad
, and
emailBody_txt
debug_txt
.
.
279
Need help?
Do you have a question about the FLASH MX 2004-USING ACTIONSCRIPT IN FLASH and is the answer not in the manual?
Questions and answers