Link:INB Home|INB English| INB русский язык|INB العربية|INB Türkiye|INB فارسی|INB Español|INB Français|INB Português|INB Deutsch|INB 國語|INB 中文|INB 日本语|INB 한국어|INB ภาษาไทย|INB tiếng Việt||[FL]Flash Tutorial Creating a Contact Form in Flash Using AS3
INB English forum
Welcome to (Industry & Native boffin) The industrial age here is full of fighting spirit, you and I both through this network space with Native biological spirit boffin came to the mad labs. home INBforum.com, come and join us Permanent name: inb-english.forumotion.com
INB English forum
Welcome to (Industry & Native boffin) The industrial age here is full of fighting spirit, you and I both through this network space with Native biological spirit boffin came to the mad labs. home INBforum.com, come and join us Permanent name: inb-english.forumotion.com
INB English forum

Welcome to (Industry & Native boffin) The industrial age here is full of fighting spirit, you and I both through this network space with Native biological spirit boffin came to the mad labs. home INBforum.com, Permanent name: inb-english.forumotion.com


You are not connected. Please login or register

《《《《《《《上一页INBforum   Go down

上一页INBforum》》》》》》》View previous topic View next topic Go down  Message [Page 1 of 1]

1[FL]Flash Tutorial Creating a Contact Form in Flash Using AS3 Empty [FL]Flash Tutorial Creating a Contact Form in Flash Using AS3 Wed Sep 22, 2010 11:01 am

Admin

Admin
Admin
This tutorial will teach you how to create a simple contact form which the users of your website can use to send you message directly from the website. The script will be written in ActionScript 3.0 and will use a PHP script to send the message through to your email inbox.
This tutorial does not require you to know PHP as the script is simple and can be implemented without modifications. In order to understand the AS3 script would have to know the basics of variables, event handling, and the basics of the URLLoader Class and the URLVariable Class. You may refer to our previous tutorials on these topics to learn more about them.
Our tutorial will be divided into three sections:

  1. Preparing the External Assets
  2. Creating the Graphical Interface in Flash
  3. Writing the Script

Preparing the External Assets


A Flash movie cannot communicate with a server or send an email message by itself. We need to use an external server-side script such as PHP or ASP to do this job. In this tutorial we will use a PHP script. Create a new folder for your project and inside this folder use any text tool a blank PHP file named mail.php.
[You must be registered and logged in to see this image.]
This file will have the responsibility of receiving our message details from the SWF movie which we will create later and then send this data to the email address we specify. Simply paste the following PHP code to do this job.<?php
$to = "yourAddress@domain.com";
$subject = ($_POST['senderName']);
$message = ($_POST['senderMsg']);
$message .= "\n\n---------------------------\n";
$message .= "E-mail Sent From: " . $_POST['senderName'] . " <" . $_POST['senderEmail'] . ">\n";
$headers = "From: " . $_POST['senderName'] . " <" . $_POST['senderEmail'] . ">\n";
if(@mail($to, $subject, $message, $headers))
{
echo "answer=ok";
}
else
{
echo "answer=error";
}
?>

You must replace the value of the $to variable with the actual email address you want to have the contact form messages be sent to.

Explaining the PHP code goes beyond the scope of this tutorial, however, the basic concept behind the code is that it assembles the information into a single message and then sends it to the email address you specify using the @mail function.
This should make our PHP script ready. Simply save it and launch Flash to start the next step.
Creating the Graphical Interface of the Form


Create a new FLA in Flash in AS3 format. Save it with the name ContactMovie in the same project folder as your PHP script.
[You must be registered and logged in to see this image.]
We are now going to create the graphical elements we need for our contact form, namely:

  1. A text input field for the email address of the sender.
  2. A text input field for the name of the sender.
  3. A bigger text area field for the body of the message.
  4. A submit button.

We are going to use ready-made components for this job. Open up the Components panel by going through Window>Components and drag an instance of the TextInput component onto the stage. You will have to resize it a little bit to have it look like the image below:
[You must be registered and logged in to see this image.]
Now that you have this field on the stage we will have to assign an instance name to it so that we can interact with it via ActionScript. While your field is still selected, access the Properties Inspector and set the Instance name of it to email_txt.
[You must be registered and logged in to see this image.]
That should do it for the first field, repeat the same process to create another field for the name of the sender of the message, after creating the instance of the component, set the instance name of it to name_txt.
[You must be registered and logged in to see this image.]
For the body of the message we need to insert an instance of the TextArea component on to the stage and set an instance name of it to message_txt.
[You must be registered and logged in to see this image.]
Finally, the last component we need to add is the submit button, to do this simply drag a button component to the stage and set its instance name to submit_btn.
[You must be registered and logged in to see this image.]
Our submit button is not fully ready yet as you might have noticed, we need to change the label so that the button actually says Submit. To do this access the Component Inspector by going through Window>Components Inspector and set the Label property of the button to Submit.
[You must be registered and logged in to see this image.]
That should do it, you should have the following elements on your stage right now:
[You must be registered and logged in to see this image.]
We clearly need more labels to explain what is what here, so use the Text Tool to write the right labels next to each of the fields. You should end up with something similar to the image below:
[You must be registered and logged in to see this image.]
That should do it. All of our graphical elements are now done. We are going to script our contact form in the next section.
Summary



  • Created the PHP file.
  • Created the FLA file and placed all the visual elements on the stage.

In the next section of this tutorial we will write the ActionScript required to gather the data from our form and send it to our PHP script.
- End of Tutorial]

http://eng.inbforum.com

上一页INBforum   Go down

上一页INBforumView previous topic View next topic Back to top  Message [Page 1 of 1]

Permissions in this forum:
You cannot reply to topics in this forum

Copyright ©2009-2016 LTD Creative Commons License
This work is licensed under a Creative Commons Attribution-NonCommercial-ShareAlike 3.0 Unported License.

IT:SINGLESERVGoogle谷歌翻译TranslateFORUMSOFTLAYERGoogle谷歌广告联盟AdSenseAsia

 

Create a forum on Forumotion | ©phpBB | Free forum support | Report an abuse | Forumotion.com