MACROMEDIA FLASH 8-LEARNING ACTIONSCRIPT 2.0 IN FLASH Manual page 641

Learning actionscript 2.0 in flash
Table of Contents

Advertisement

4.
Create four input text fields on the Stage, and give them the following instance names:
emailFrom_txt, emailTo_txt, emailSubject_txt, and emailBody_txt.
5.
Create a dynamic text field on the Stage with the instance name debug_txt.
6.
Create a button symbol, drag an instance on to the Stage, and give it an instance name of
submit_btn.
7.
Select Frame 1 in the Timeline, and open the Actions panel (Window > Actions) if it isn't
already open.
8.
Enter the following code in the Actions panel:
this.submit_btn.onRelease = function() {
var emailResponse:LoadVars = new LoadVars();
emailResponse.onLoad = function(success:Boolean) {
if (success) {
debug_txt.text = this.result;
} else {
debug_txt.text = "error downloading content";
}
};
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");
};
This ActionScript creates a new LoadVars object instance, copies the values from the text
fields into the instance, and then sends the data to the server. The CFM file sends the e-
mail and returns a variable (
in the
debug_txt
Remember to change the URL www.yoursite.com to your own domain.
9.
Save the document as sendEmail.fla, and then publish it by selecting File > Publish.
10.
Upload sendEmail.swf to the same directory that contains email.cfm (the ColdFusion file
you saved and uploaded in step 2).
11.
View and test the SWF file in a browser.
For more information, see the LoadVars entry in the ActionScript 2.0 Language Reference.
or
true
false
text field.
) to the SWF file called
Using HTTP to connect to server-side scripts
, which appears
result
641

Hide quick links:

Advertisement

Table of Contents
loading
Need help?

Need help?

Do you have a question about the FLASH 8-LEARNING ACTIONSCRIPT 2.0 IN FLASH and is the answer not in the manual?

Subscribe to Our Youtube Channel

This manual is also suitable for:

Flash 8

Table of Contents