Creative COW SIGN IN :: SPONSORS :: ABOUT US :: CONTACT US
ADOBE FLASH: HomeFlash ForumFlash TutorialsFlash Video TutorialsWeb Streaming ForumAdobe FlashPodcast

Re: Adding an e-mail flash form to my flash site

Cow Forums : Adobe Flash
VIEW POSTS   •   ADD A NEW POST   •   SEARCH   •   CHANGE FORUM
Respond to this post   •   Return to posts index   •   Read entire thread


Re: Adding an e-mail flash form to my flash site
by Pieter Helsen on Apr 5, 2009 at 10:59:41 am

THIS IS AN AS3 EXAMPLE

Drag a checkbox component (Window > Components I think) onto the stage and give it an instance name. (like checkBox)

Then use the textfield tool to draw the fields that you need and again, give them an appropriate instance name. In my example, I'll use name_txt and msg_txt.

Then draw a button that will act as send button. Press F8 to 'Convert to Symbol'. Check MovieClip (you could work with a Button instead of a MovieClip, but I like working with MovieClips better.) Give the button another instance name in the properties panel. Like send_mc.

Next, put this actionscript onto the main timeline where you placed your form:


import flash.events.MouseEvent;
import flash.net.URLRequest;
import flash.net.URLRequestMethod;
import flash.net.URLVariables;
import flash.net.navigateToURL;

// Add an eventlistener that will respond when the user clicks the send button
send_mc.addEventListener(MouseEvent.CLICK, mouseClickHandler);

// This function is called when the user clicks the send button
function mouseClickHandler(evt:MouseEvent):void {
// Retrieve the values from the textfields and checkbox
var name:String = name_txt.text;
var message:String = msg_txt.text;
var check:string = getCheckBox();

// Create a URLVariables object and store the variables to be sent to your PHP script
var vars:URLVariables = new URLVariables();
vars.name = name;
vars.message = message;
vars.check = check;

var request:URLRequest = new URLRequest();
request.data = vars;
request.method = URLRequestMethod.POST;
request.url = "myUrl.php" // ENTER YOUR WEBSITE HERE

navigateToURL(request);
}

// Checks if your checkbox is checked and returns a string
// When checked, "Selected" is returned else "Not selected" is returned
function getCheckBox():String {
if(checkBox.selected == true){
return "selected";
}else{
return "not selected";
}
}


This code sends all the variables to your PHP script using the POST method. So in your PHP script you would use $_POST['name'] and $_POST['check'] to get the variables. Now you just have to send the e-mail.

Good luck.

Kind regards,
Pieter

General notice: from now on, I would like to ask everyone to put [AS2] or [AS3] (corresponding to the version of actionscript you are using on your project) in front of their post titles when the question is actionscript related! Please help us help you faster. Thank you.


Respond to this post   •   Return to posts index   •   Read entire thread


Current Message Thread:


Related Tags:
DI   |   Flash



Note: If you are a registered user please click here to login before posting.

Your post will not be accepted if your name and email address are not registered in our database. Click here if you do not have an account.

Name
E-Mail Address
Subject
E-Mail me when someone responds
Just This Message   Entire Thread   None  

Message:



Note: The following are HTML characters and may cause parts of your post to disappear if not used correctly: < > &
To include any portion of the post in your response, highlight the desired text and hit the "Q" key. Read more...



Add your message signature


 


Note: By clicking "Post Direct" button above, you are agreeing to the Creative Cow's Code of Conduct.



FORUMSTUTORIALSMAGAZINETRAININGVIDEOS - REELSPODCASTSEVENTSSERVICESNEWSLETTERNEWSBLOGS

© CreativeCOW.net All rights are reserved.

[Top]