Flash AS3 Contact Form Using PHP

To continue in the tradition of my AS3 scrollbar source code I released a few months back, I’m now giving away the source code for my AS3 contact form class I’ve been using in my other Flash templates, specifically the one from Cedar.

The contact form class is super-customizable and simple to use. I’ve used it in lots of projects and it’s easy to make it look different every time. Here is the basic usage:

  1. import com.warmforestflash.ContactForm;
  2. var contactForm:ContactForm = new ContactForm();
  3. addChild(contactForm);

And here is a preview:

Get Adobe Flash player

Pretty much everything can be easily customized including all the colors and text and validation copy. Here is how you would customize it:

  1. import com.warmforestflash.ContactForm;
  2. var contactForm:ContactForm = new ContactForm();
  4. // Label settings
  5. contactForm.nameText = "Type your name here";
  6. contactForm.emailText = "Type your email here";
  7. contactForm.messageText = "Type your message here";
  8. contactForm.sendButtonText = "CONTACT ME";
  9. contactForm.sendingText = "Sending message…";
  10. contactForm.errorEmailText = "Your email is not valid.";
  11. contactForm.errorServerText = "Server problems.";
  12. contactForm.confirmationText = "Thanks for contacting me!";
  14. // Color settings
  15. contactForm.textColor = 0xffffff;
  16. contactForm.borderColor = 0×222222;
  17. contactForm.backgroundColor = 0×000000;
  18. contactForm.selectedBorderColor = 0x05b59a;
  19. contactForm.selectedBackgroundColor = 0×000000;
  20. contactForm.selectedBlurAmount = 50;
  21. contactForm.sendButtonTextColor = 0xffffff;
  22. contactForm.sendButtonTextRollOverColor = 0xffffff;
  23. contactForm.sendButtonColor = 0x05b59a;
  24. contactForm.sendButtonRollOverColor = 0xff4400;
  25. contactForm.errorColor = 0xff4400;
  26. contactForm.confirmationColor = 0x05b59a;
  28. // Layout settings
  29. contactForm.nameWidth = 400;
  30. contactForm.emailWidth = 400;
  31. contactForm.messageWidth = 550;
  32. contactForm.messageHeight = 200;
  33. contactForm.verticalSpacing = 10;
  35. addChild(contactForm);

And here it is customized:

Get Adobe Flash player

I’m also including an XML-powered version for people who don’t own the Flash authoring software or who don’t know any ActionScript at all. You can just drop this into an HTML page and customize everything straight through the XML without having to open Flash or mess with any ActionScript. It’s a simple way to add a contact form to any website.

The script that actually sends the email is written in PHP so the web server you upload it to will need to support PHP in order for the email to send.

» Download the contact form class and XML version

Feel free to use this code in any way you want other than selling it.

Have fun!


Related posts:

  1. Free AS3 Scrollbar: Fullscreen and Resizable
  2. AS3 Dotted Line Class
  3. Accessible Flash Nav: Right-Click Links to Open in New Window Using AS3
  4. Simple Sanity-Saving Tip for All Timeline-Based Flash Projects
  5. Top 8 Resources for Learning ActionScript 3

138 Responses to “Flash AS3 Contact Form Using PHP”

  1. 1 Michele

    Hi there, newbie ti flash here, but I’d like to insert this form in a flash site I’m building. Trouble is, I’m not sure how to incluse this in a page….I mean, I can call up any page I want on my site, but son’t know how to insert this form. I have followed all instructions in your file, but you’ve probably omitted what would be abvious to anyone using flash or AS3 on a regular basis.
    Any help would be appreciated.

  2. 2 Jay


    Hello. The basic usage is as follows:

    import com.warmforestflash.ContactForm;
    var contactForm:ContactForm = new ContactForm();

    That should be all you need if the “classes” folder is in the same folder as your FLA files. Also make sure you follow the instructions in the help file to set your classpath. Your site will need to be coded in AS3 to be compatible.

    Hope that helps.


  3. 3 Steve

    Hi Jay,
    This will be a great looking form, however….
    When I test this in CS3 I get the following error…
    “1180: Call to a possibly undefined method FontSmall.” It points to line 370 in the ContactForm.as file.

    Not only that, but I’d like to change the font and font size used in both the form layout and in the fields where the respondant types. I suppose I would go to the ContactForm.as to change the font, but I’m not sure how to do it.

    Thanks for your help. Steve

  4. 4 Jay


    In “contact_form.fla” you’ll need both the fonts included in the library FontSmall and FontText – double click on them to change them to a font you have installed on your computer. In “ContactForm.as” see lines 243 and 373 for setting the font size.

    Hope that helps.


  5. 5 Vlad

    Hi Jay,

    Thanks for your post. I’m working on a flash site now and trying to add a contact form. I have downloaded five already. And no one is working. A local server with PHP is launched (Server2Go). Do you have any ideas what could it be the problem?

    Thanks in advance. Vlad

  6. 6 Jay


    Are you getting the “server error” message when you try to send? If so the problem probably lies with your server.


  7. 7 Rusty


    Very nice work! Is this configured for PHP5, or PHP4? I seem to be having issues with PHP5…

    Thanks in advance.


  8. 8 Jay


    It should work for both PHP4 and PHP5 – I just tested it on two different server configs and it sends fine in either.


  9. 9 Joe Dassler

    Dear Mr jay,
    I hope that you can be of assistance.This is my first flash site ihave built using all kinds of books,but they do not have this information.i am trying to add a contact form to the contac us webpage.I have used as3 and everything is on the first frame.The site has five buttons(home ,contact us, etc).i just use url loader to load pages onto frame.Is there a way of adding the contact form to the contact us page(the .txt files all load into the same textfield on the same frame.)i hope that when user clicks on this contact us button the .txt file is loaded and also a contact form is loaded…Thanks

  10. 10 Jay

    @Joe Dassler

    This is the usage for the contact form:

    import com.warmforestflash.ContactForm;
    var contactForm:ContactForm = new ContactForm();

    Just add that to your contact page. Hope that helps.


  11. 11 Javie

    Hi Jay,

    I came across your site the other day while searching for flash components.. you’ve got some great stuff!

    Anywho, I downloaded your contact form to try it out for a flash site I’m building and I’ve come across a problem that I can’t seem to figure out.

    When adding the form to the display list, the fields and submit button come through, but the rest of the form’s text is not visible.

    I don’t get any errors or anything, either. I tried adjusting font colors, but nothing.


  12. 12 Javie

    Oh, also, how would I go about adding form fields? Thanks!

  13. 13 rdh

    Hi…I’m using older ‘gs’ classes… already updated but seems collapse my framework…I’m using Gaia…is there any workaround to use old ‘gs’ classes? mine is 2 or 3 I think…

  14. 14 Jay


    If the text isn’t showing up that probably means you are republishing without having the font installed on your computer. You’ll need to change it inside the FLA to a font you own.

    To add new form fields, you should be able to just follow along in the code in “ContactForm.as” to see how I created the form fields and then copy and paste the code to create more.


  15. 15 Jay


    The contact form uses the gs TweenLite classes minimally. Mostly just for tweening the rollovers and whatnot. If you search through the AS file you could probably just comment the lines out that use TweenLite.


  16. 16 rdh

    OK, I’ll try…really nice stuff you had…thanks for your help.

  17. 17 Jk_

    Thank you for sharing! I was so lazy to write down my own contact form. Your code is clean and it has been a pleasure to work with it. Cheers mate. Jk_

  18. 18 Trang

    Great work! For those who don’t want to use any custom fonts you can go into the ContactForm.as in folder classes/com/warmforestflash/ and edit the code
    1) line 240 delete “var font:Font = new FontText();”
    2) line 242 change “tf.font = font.fontName;” to “tf.font = ‘Verdana’;” replace Verdana with the name of the font you want to use
    3) line 369 delete “var font:Font = new FontSmall();”
    4) line 371 chnage “tf.font = font.fontName;” to “tf.font = ‘Verdana’;” replace Verdana with the name of the font you want to use

    This way you’ll save more memory, if you’re not planning to use a custom font

  19. 19 Zilus

    Great! awsome.

    Thanks for publishing this, Im starting in AS3 and you helped me a lot.

    Great website.

  20. 20 Jay


    Thanks for the tip! I’m sure others will find it useful.


  21. 21 Jk_


    I can’t get it works on PHP5 config!


    Any ideas on how i could resolve that?


  22. 22 Jay


    I’m not a PHP guru or anything so I’m really not sure unfortunately. Double check that you have changed the email address to your own in both places like it says in the help file.


  23. 23 sonambvlo

    to those having a problem with FontSmall and FontText, i realized after messing with it for a while that if the two are set to the same font it doesn’t work, but if they are different fonts it works fine, no error.

  24. 24 Jk_

    Ok i solved my problem.

    I replace this line:

    $headers .= “Reply-To: ” . $senderEmail . “\n\n”;

    by this one

    $headers .= “Reply-To: ” . $senderEmail;

    And it works perfectly.



  25. 25 Matthew

    Hello, I have successfully integrated the form with my website, however, I would like to have the form centered (left justified) on my stage. Can anyone help?

  26. 26 Nanka

    Hi Jay,
    Thanks for the great tutorial! I’m trying to use it for the contact page on my website but I keep getting this error:

    Error: Error #2136: The SWF file file:///Macintosh%20HD/Users/user1/Documents/Contact.swf contains invalid data.
    at classes.com.warmforestflash::ContactForm/frame178()

    Any help or advise you can give would be much appreciated! Thanks!

  27. 27 Art

    First GREAT JOB.
    Second I had problem cuz my server needed stmp validation so I did little research and changed the php page to :

    $mail = new PHPMailer();

    $mail->IsSMTP(); // send via SMTP
    //$mail->SMTPDebug = 2;
    $mail->Host = “smtp.plantium.com.br”; // SMTP servers
    $mail->SMTPAuth = true; // turn on SMTP authentication
    $mail->Username = “info@plantium.com.br”;
    $mail->Password = “xxxx”;
    $mail->From = “info@plantium.com.br”; //E-MAIL DO REMETENTE
    $mail->FromName = “$senderName”; //NOME DO REMETENTE
    $mail->AddAddress(“info@plantium.com.br”,”Site”); //E-MAIL DO DESINATÁRIO, NOME DO DESINATÁRIO
    $mail->AddReplyTo(“$senderEmail”,” $senderName “); //OPCIONAL PARA DEFINIR OUTRO EMAIL DE RESPOSTA
    $siteName= “plantium.com.br”;
    $mail->WordWrap = 50; // ATIVAR QUEBRA DE LINHA
    $mail->Subject = “Monitor de Colheita”; //ASSUNTO DA MENSAGEM
    $mail->Body= “From: $senderName
    Email: $senderEmail
    $message = $emailBody; //MENSAGEM NO FORMATO HTML
    echo “returnValue=0″;
    echo “Erro: ” . $mail->ErrorInfo;
    echo “returnValue=1″;

    Now my problem is how the heck do I add extra field?? Also I treid to change the info in setting.xml didnt work, no change happened… I changed nameText=”erreree”, nada happened..
    Any ideas?

  28. 28 Art

    forget anout the settings.xml I was modified the original and was uploading the otherone lol…jejeje sorry let see if i can add extra field!

  29. 29 Jay


    Thanks for the tip on the PHP code.

    To add new form fields, you should be able to just follow along in the code in “ContactForm.as” to see how I created the form fields and then copy and paste the code to create more.

  30. 30 Jay


    I’m not really sure – it looks like you are getting that error from something else on your site since it is showing a frame error and there aren’t any frames in my contact form code.

  31. 31 Jay


    Here is a good tutorial on center aligning movieclips on the stage:


  32. 32 Art

    Dear Jay,

    I got extra field but the swf is not editable… u cant type on it also the txt beside(left) the field is gone! any ideas what I am doing wrong?
    Do I still control it from the xml , or now that i modify the actionscript one and exported at swf, is not modifiable from xml anymore?

  33. 33 matt

    hey jay,
    for some reason no text is showing up in the “contact me button”

    i have the var as so contactForm.sendButtonText = “CONTACT ME”;
    any ideas?

  34. 34 Richard Lowe

    Hey Jay,

    I’m a little desperate and embarasssed to bother you over what I’m sure will turn out to be something silly, but maybe you’ll be kind enough to help. I bought my flash website as a template, and customized it myself. Not very well, but at least I tried. The problem I have is I don’t know how to set up the mail “contact me” feature to work, at all. As in, I don’t even know how to find the code in my file to get it to work.

    I have two or three files within my template that have this form, movie files & a button file, but I’m not sure which one makes it tick, and how to get to the portion of the PHP code to change the existing information.

    I contacted the place where I bought and they never responded. I’ve now had the site for over a year and it has never worked, and it’s becoming embarrassing. Any help you can offer would be great!!!

    I can always send you the file to have a look…?


  35. 35 Richard Lowe

    I found this today while searching through all files, meanwhile, the file I have is only a FLA file, I don’t have separate folders….

    on (rollOver) {
    on (rollOut) {
    on (release) {
    _parent.t1_2 = “Your full name:”;
    _parent.t2_2 = “E-mail address:”;
    _parent.t3_2 = “Your telephone:”;
    _parent.t4_2 = “Message:”;

  36. 36 Liquid

    First of all.. fantastic product! And thank you for making it available for free!

    What I have done is uploaded the Flash version to a test directory on my server just to see if it functions and to make sure PHP is configured correctly on the server. I changed the .php file to reflect my own email address. I filled out the form and sent a test message. It worked like a charm as a stand alone page. I received the email within a matter of seconds.

    So the next step was to try to incorporate it on my own site. Now, I am still better with as2 than as3 so this may be the “old” way of doing things… I have on the first frame of the stage a movie clip instance called contentMC.

    Inside the contentMC timeline are two layers. The first layer contains these actions:


    var imageRequest:URLRequest = new URLRequest(“assets/deploy/contact_form.swf”);
    var imageLoader:Loader = new Loader();

    I have the files for the contact form stored in a directory called assets so I figured modifying the path in this action was required.

    On the second layer in the same frame is an empty movie clip with an instance name of contactContainer. I have this empty movie clip placed on the stage where I would like the contact form to appear.

    So now back on my main timeline I have a button that takes me to the “contact” frame of the contentMC. So, in theory, that should load the contact_form.swf into the contactContainer movie clip… and it does! :) One small problem though.. When I test it on the server I fill out the form and click “Send Message” at the bottom. I see the green text in the bottom left that says “Sending…” but thats where it stops. I never get an email in my inbox and “Sending…” never goes away…

    Any ides?
    Thanks a lot in advance

  37. 37 Victor

    Hello Ive tryed everthing to make this work but its giving me 1180 error call to a possible undefined method Font small var font:Font = new Font for line 240 and 370.. any help Please


  38. 38 Brent

    I must be missing something. When I open up the files I see nothing. I made the modifications to the .php file and put everything on my server but still see nothing.
    And what is the file structure I should use on my server? Do I take the files out of the deploy and src folders or leave them in there.


  39. 39 Jay


    The XML version and AS version are completely separate versions. I’m not sure what code you edited so I’m not sure why it’s not working for you anymore.

  40. 40 Jay


    Sounds like a font issue – read through the other comments to see how to change the font to something you have installed on your computer.

  41. 41 Jay

    @Richard Lowe

    The code you are pasting isn’t even from my file so I’m really not able to help you debug it. :)

  42. 42 Jay


    Sounds like maybe it can’t find the PHP file? I think you said you moved things to a different directory. Make sure the PHP file is with it.

  43. 43 Jay


    Sounds like a font issue – read through the other comments to see how to change the font to something you have installed on your computer.

  44. 44 Jay


    It explains how to upload things in the help file. Basically you upload everything in the “deploy” folder.

  45. 45 Ricky

    Great Work!!, BTW I have found another php flash contact us form . This is basically a as3 class and we need to create an instance of of it, edit one variable in php to add your email id and and thats it. If you wish to have look on it.



  46. 46 urbanczyks

    I get an server error:

    Parse error: syntax error, unexpected ‘{‘ in /home/intersid/public_html/pliki/testy/AS3Gall/php/contact_form.php on line 1

    witch is quite strange, I didn’t even edit the php file, using PHP5 any one got similar problems

    btw. nice work with the form

  47. 47 Amanda

    Hi Jay,
    I’ve included the contact form on my flash website but now how do i link it to my email?? When i click the send button, it seems like it’s not talking with my email?

    Below is the code i’m using.. am I missing something? Is that why it’s not sending web contacts to my email address?


    contact_name.text = contact_email.text = contact_subject.text =
    contact_message.text = message_status.text = “”;

    send_button.addEventListener(MouseEvent.CLICK, submit);
    reset_button.addEventListener(MouseEvent.CLICK, reset);

    var timer:Timer;
    var var_load:URLLoader = new URLLoader;
    var URL_request:URLRequest = new URLRequest( “send_email.php” );
    URL_request.method = URLRequestMethod.POST;

    function submit(e:MouseEvent):void
    if( contact_name.text == “” || contact_email.text == “” ||
    contact_subject.text == “” || contact_message.text == “” )
    message_status.text = “Please fill up all text fields.”;
    else if( !validate_email(contact_email.text) )
    message_status.text = “Please enter the valid email address.”;
    message_status.text = “sending…”;

    var email_data:String = “name=” + contact_name.text
    + “&email=” + contact_email.text
    + “&subject=” + contact_subject.text
    + “&message=” + contact_message.text;

    var URL_vars:URLVariables = new URLVariables(email_data);
    URL_vars.dataFormat = URLLoaderDataFormat.TEXT;

    URL_request.data = URL_vars;
    var_load.load( URL_request );
    var_load.addEventListener(Event.COMPLETE, receive_response );

    function reset(e:MouseEvent):void
    contact_name.text = contact_email.text = contact_subject.text =
    contact_message.text = message_status.text = “”;

    function validate_email(s:String):Boolean
    var p:RegExp = /(\w|[_.\-])+@((\w|-)+\.)+\w{2,4}+/;
    var r:Object = p.exec(s);
    if( r == null )
    return false;
    return true;

    function receive_response(e:Event):void
    var loader:URLLoader = URLLoader(e.target);
    var email_status = new URLVariables(loader.data).success;

    if( email_status == “yes” )
    message_status.text = “Success! Your message was sent.”;
    timer = new Timer(500);
    timer.addEventListener(TimerEvent.TIMER, on_timer);
    message_status.text = “Failed! Your message cannot sent.”;

    function on_timer(te:TimerEvent):void
    if( timer.currentCount >= 10 )
    contact_name.text = contact_email.text = contact_subject.text =
    contact_message.text = message_status.text = “”;
    timer.removeEventListener(TimerEvent.TIMER, on_timer);


  48. 48 Jay


    See the included help file – it’s all explained there. :)

    Also the code you pasted isn’t from my contact form – not sure where you got that from.


  49. 49 Juan

    First off, thanks for sharing with us your great work.
    I know you are no php guru like you stated before, but the form is not working on a server with PHP Version 5.2.9-2, I get server errors. Although, I tried it on another server with PHP Version 5.2.6-1 and works like a charm. Unfortunately I need it to work on the 5.2.9 one.

    Maybe you or anybody else here is having the same problem as me? Just trying to figure out the server incompatibility…



  50. 50 Jay


    Really not sure why it wouldn’t work on different PHP versions. Anyone else who knows more about PHP feel free to jump in…

  51. 51 Juan

    Alright, I got it to work finally… I figured I would post up my solution as it might help others as well.

    In my case the problem is not the version of the PHP but is the server that needs smtp validation (which I did not know). Below is the complete code which of course works for the server where I’m hosting, if it doesn’t work for you, then ask your hosting provider for the smtp email validation code for php forms (which in my case are the first 6 lines of written code below the “<?php".



    // Please specify your Mail Server – Example: mail.yourdomain.com.

    // Please specify an SMTP Number 25 and 8889 are valid SMTP Ports.

    // Please specify the return address to use
    ini_set('sendmail_from', 'email@youremail.com');

    echo"Error: No email address found";
    $senderName = $_POST['senderName'];
    $senderEmail = $_POST['senderEmail'];
    $senderMessage = nl2br($_POST['senderMessage']);
    $headers = "MIME-Version: 1.0\r\n";
    $headers .= "Content-type: text/html; charset=iso-8859-1\r\n";

    // 1) Edit the first line below to match your email address
    $headers .= "From: email@youremail.com \n”;
    $headers .= “Reply-To: ” . $senderEmail . “\n\n”;

    // 2) Then edit the following two lines to match your site name and email address
    $siteName = “yoursite.com”;
    $to = “email@youremail.com”;

    $toSubject = “Message from $senderName via $siteName”;
    $emailBody = “From: $senderName
    Email: $senderEmail
    $message = $emailBody;
    $ok = mail($to, $toSubject, $message, $headers);
    echo “returnValue=1″;
    echo “returnValue=0″;

  52. 52 James


    I am completely new to all this so please excuse the simple question here. I am working with a flash site right now in as3. I downloaded the contact form file and I am not sure which one to import to my stage?? There are numerous html, js, and as files in numerous folders which is throwing me for a spin. If I simply wanted to import the contact form and appropriate fla/as files which ones would they be?? I have saved both as3 contact form folders onto my desktop, acstionscript version and xml version. Do i also need to set up button/movie clips for this? I would assume that they are already set up, correct?


  53. 53 George

    Hi Jay,

    One quick question, I’m using your actionscript version of the form, but I want some of the settings , i.e. messages, to be retrieved through the XML file!!

    How can I do that???


  54. 54 Jay


    Read through the included help file – that should answer a lot of your questions. It’s an AS class so you don’t really import anything to your stage. You just do it through code like shown in the demo example. Hope that helps.


  55. 55 Jay


    Not sure if I understand your question. Both versions have exactly the same settings. Use the XML version if you want to set everything through XML and use the AS version if you want to set it through ActionScript.


  56. 56 George


    I know that they have exactly the same settings. I only need to change the language messages, through XML. And because the XML version doesn’t have a .fla file, that’s why I ask you how to do this!


  57. 57 Jay


    Ok I see what you are asking – I really can’t help with that though. There are lots of good tutorials out there showing how to load in and use XML data in Flash.


  58. 58 George


    Mate I know how to manipulate the XML data, the reason I have ask this, is to know if the settings that I would pull through the XML will be overwrite the default settings of the form fields written in AS! If so, then I have no problem!!!
    To be completely honest I haven’t try that due the lack of time, but I will! :)


  59. 59 David


    Firstly let me say thank you for putting this up for actionscript 3. I have added the actionscript code to my flash website but the whole contact form shows up on the top left corner of the screen cutting off the nav buttons and anytime i navigate away from the contact us page the contact form shows up on the other pages. Is there anyway i can rectify this issue, i will be so grateful for your help.


    Thanks again

  60. 60 Flo

    Hey Jay,

    first of all I’d like to tell you that I really love your form!

    It’s easy to customize and working great.
    I just have one prob:

    I also posted it on several blogs without response…

    I create the instance of your form at frame 55 of my main mc. The problem is, that it stays there and does not disappear when I go to a different section of the page. In my case this means : if I go to another frame.

    Could you please give me a hint for the code?? I’m really desperate!!!
    Thank you sooooo much,


  61. 61 Jay

    @David & @Flo

    Sounds like the issue is with your how your site is setup and not the contact form so I really can’t provide support for that. :)


  62. 62 vapn

    Hi nice work,
    I am creating my web site at google site and wanted to use this contact form in there. I can not use this form in google site because it does not allow php scripting. I think I need to host this contact form at some other server. Can you guide me how to do it?

    Also, can anyone suggest me any free hosting sites where I can host my contact form?
    I know this is not the right platform for asking such question. I will be very thankful if anyone help me in this matter.

    Thanks a lot,

  63. 63 Sonyl

    Thanks! Saved me an hour or so on a tight deadline.

  64. 64 jcon

    This worked great…took a while to figure out for a novice like me, but I have it working. Read the notes before posting a question….answers are in the comments.



  65. 65 Sebastian

    Great file, free too! kudos to you. However, just like everyone I’ve run into some problems. My host said they don’t support CGI, is this a problem?

    When sending my mail (tripple checked the .php) I just get “sending…” and after 2-3minutes still nothing. My host is One.com (hate them…)

  66. 66 Sebastian

    I also get this error on firefox. OSX mac.
    “Error: Error #2101: The String passed to URLVariables.decode() must be a URL-encoded query string containing name/value pairs.
    at Error$/throwError()
    at flash.net::URLVariables/decode()
    at flash.net::URLVariables()
    at flash.net::URLLoader/onComplete()”

    How do I fix this?

  67. 67 Jay


    You shouldn’t need CGI support on your host – just PHP. For your other error see this thread:


    Hope that helps.


  68. 68 Zach

    I’m trying to incorporate the contact form into my contact page. I says message sent and looks like everything went well…but the message never shows up in my inbox. I’ve check the junk folder and I have checked to ensure the correct e-mail address…

    Any Help is appreciated

  69. 69 Jay


    If it’s saying message sent then it should be sending. Double check that you have changed the email address in both places like it says in the help file.


  70. 70 Zach

    The e-mail is correct in both places and it’s still not delivering. I switched it over to a different server and now it gets stuck on the “sending message…” I’m stumped. Does the siteName make a difference? I was trying to send it to my school e-mail account. I also tried my hotmail e-mail address?

    Any Help?

  71. 71 Jay


    I really have no idea – I’ve never heard of that before. If your server supports PHP and you changed the email addresses it should send.


  72. 72 Ernie

    I keep getting these errors???


    Really digging your site!

    Thanks for the help.


  73. 73 Jay


    Looks like it can’t find the class file. The help file should show how to set everything up.


  74. 74 Nicolas

    Hi there Jay,

    thanks a lot for this absolutely awesome (and free!!) contact form.

    I got everything to work except that I want to align right the name and e-mail field (and the text that goes with it) and am not figuring this one out.. Any help is appreciated.



  75. 75 Jay


    In “ContactForm.as” see the function createContactForm that begins on line 235. You should see the code in there which sets the positioning of the fields, for example this line sets the x position of the name field.

    _nameTextField.x = 3;

    Hope that helps.


  76. 76 yasmin

    really very useful but i hv a problem with embed fonts. the text was disappear until i disable the embedfonts .
    can any one help me

  77. 77 jasmine

    php code not working, i try to setup this code on php server , fill all text , and confirmation message appear send successfully!!!

    i check my email no emails come
    please help me

  78. 78 Jay


    If you scroll through the comments there should be some info on changing the fonts.


    Make sure you follow the instructions in the help file and double check that you have changed the email address in both places.

    Hope that helps.


  79. 79 mahesh

    Hi there,

    am new to flash and php things,

    I tried every thing but its saying server error please try again.
    Could pls help me.

  80. 80 Jay


    I’m not sure what else to say other than follow the instructions in the help file and scroll through the comments here. Hope that helps.


  81. 81 Zach

    This isnt a question, but this may help people. If you can’t get this (or any contact form) working, it has to do with SMTP and ports. SMTP on Port 587 will not relay a message unless the contact form lives on the same server as the actual email address. For example, if your website is ‘example.com’ and you are trying to send it to your gmail address it will not work! For the form to work at ‘example.com’ the e-mail should be something like ‘admin@example.com’.

    This problem would cause it to get stuck at “sending message…” or it might even say “message delivered” (and appear as if everything worked), but then no message would actually be delivered.

    Sorry For the lengthy post…But hope it helps

  82. 82 Jay


    Thanks for posting that tip. I just did a quick test though and was able to have it send to my Gmail address without any issues. Maybe it depends on how your server is setup? It might help others though who are having problems so I’ll be sure to refer them to your posting in the future to see if it helps.


  83. 83 marky

    Hey Jay,

    just read the entire forum with no luck…installed your form, modified the php and uploaded it to my server, when i submit it just stays on sending. I’ve got working php html forms on a few pages which work fine and i have absolutely no idea why this wouldn’t work :(

    Thanks in advance if you get the chance to reply!


  84. 84 Jay


    Other than following the instructions in the help file and reading the post/comments here I really have no idea.


  85. 85 Luigi Vercotti

    I am trying to use your email form which is working alone pretty fine :-) not like the others from other sites.
    But when I load your form as external file which is ok too, but when I am trying to fill the form and then I click “send” the output says:

    Error: Error #2101: The String passed to URLVariables.decode() must be a URL-encoded query string containing name/value pairs.
    at Error$/throwError()
    at flash.net::URLVariables/decode()
    at flash.net::URLVariables()
    at flash.net::URLLoader/onComplete()

    Can you please, please help me somehow. I spent lots of hours and I started to be bit desperate.
    Take care,

  86. 86 Lukas T,

    Thank you very much for your code and files. I will use them for personal use. May I suggest that you maybe explain that the files in the “deploy” folder need to be uploaded with out the folder and straight to server. At least that how it worked for me and when I had them in a folder it did not work. I don’t know how you have the patience to answer all these questions even some with AS3 tips. You are doing a great job, thanks.

  87. 87 Chris

    I have what is I hope is a very simple question. I am very new to flash and am creating a flash website using AS 3.0 with help books, tutorials, and any other information I can find. I found this page and it is exactly what I am looking for. My question is how do I position the form so the registration point is not at 0,0. I have looked through the code but cant figure out which number I need to modify. Thanks in advance!


  88. 88 Chris

    I figured it out..thanks!

  89. 89 Bill

    I’m having the same problem with the smallFont and fontText issue. I’m very new to a lot of this and need some very specific instructions on how to “add those fonts to my library”. I have a site basically built so I just dropped the necessary code on the timeline and put the associated classes in their respective places.

    I think it might work; however, I still may need to reposition the fields so they fit in with my design. Any help you could give me would be great.


  90. 90 Chris

    This question refers back to adding fields to the contact form. I read earlier that you said to just go through the code and duplicate what you had. I understand that part of it, however lets say I want to add a Subject Fiend. Will the php file need to be modified in order to accommodate the new subject field?



  91. 91 grandmother

    It is wonderfull and so clear written. Thanks for shareing it. I don’t know how you have the patience to answer the same questions!!!
    My problem is : when I click CONTACT ME I see for a little moment “Sending message…” and later red “Server problems.” In this moment I see a new post on gmail notyfier. Gmail displays it correctly. My friend sended trial post to me with the same result.
    I used AS version and chanded it a little. font=arial, embed=false. In polish language there is a lot of special fonts. I think arial is on every computer).
    Now I added 2 fields and changed the x,y position on the side but i can’t use it until the 3 fields contact form will work correctly.

    I will be so grateful for your help.
    Sorry for my english. I’m a polish retired woman.
    A trial version of this contact form is on

  92. 92 Roger

    alright for some people who have been receiving the “1180 error call to a possible undefined method Font small var font:Font = new Font for line 240 and 370″ one way to try to fix it is by opening the source file (contact_form.fla), export the two library fonts that are stored, and insert them to whatever other fla file you are trying to embed this to. I was having the exact same problem, but this got it fixed. i know it’s a bit late…. but… someone might run into this problem in the future!

  93. 93 Chris

    Ok, this question might be a little out of left field but,would anyone be able to point me in the direction on how to alter/write the php associated with this script to send the user information into a database as opposed to the email? Thanks in advance!

  94. 94 Chris Jackson

    I have a simple question. How do I remove the little arrow on the ‘Send Message’ button. I’m referring to the one that looks like this >.

  95. 95 grandmother

    You have to read carefully all the as code!
    it’s just the arrow:

    private function createPixelArrow(c:uint):Sprite
    var t:Sprite = new Sprite();
    t.graphics.beginFill(c, 1);
    t.graphics.drawRect(0, 0, 1, 1);
    t.graphics.drawRect(1, 1, 1, 1);
    t.graphics.drawRect(2, 2, 1, 1);
    t.graphics.drawRect(1, 3, 1, 1);
    t.graphics.drawRect(0, 4, 1, 1);
    t.name = “pixelArrow_mc”;
    return t;

    and it is used in:
    private function createSendButton():Sprite
    var ar:Sprite = createPixelArrow(sendButtonTextColor);
    ar.x = 3;
    ar.y = 4;
    I think you can change or remove it without problems.

  96. 96 Chris W

    so, i’ve put everything into the actionscript and everything comes up correctly, the only problem i’m having is that when I publish and view the .html file, I can not click or edit any of the text fields. I can’t find any kind of problem with it that would make it do that. Please help.

    And thank you so much for making this available for free! You’ve saved me hundreds of hours of headaches : )

  97. 97 Chris W

    Another issue I am having is when I navigate away from the ‘contact’ page, and say, try to go to the home, portfolio, or resume pages, the contact form follows and will not go away.

  98. 98 Amy

    I am having the exact same problem as Chris W’s last post, with my form not going away. Also, can you help me by being more specific about how to change the x&y location of the form?

  99. 99 Jroni


    Send Button Text Missing?

    Check “sendButtonText” in the FLA and line 68 “sendButtonText” in ContactForm.as and make sure they both read the same. I had the same problem and for some reason, one of them was set to “Contact Me” instead of “SEND MESSAGE”

    If Matt doesn’t see this, I hope it could possibly help somebody else.

  100. 100 David Watts


    I just want to say thanks for a great resource. It worked well for me, there were a few pitfalls but everyone else had already fallen in them and you pulled them back out with your replies. Thanks a bunch.


  101. 101 Dabe

    I am getting this error on the site within the browser. Please help
    Error #2044: Unhandled ioError:. text=Error #2032: Stream Error. URL: http://www.mywebsite.com/site/contact_form.php
    at com.warmforestflash::ContactForm/validateForm()
    at com.warmforestflash::ContactForm/onSendButtonClick()


  102. 102 sascha

    I really wanted to stop by and thank you alot! i have been looking for quite some time till i found your well-structured, very well documented FREE script. AWESOME. You Rock. :)

  103. 103 Don Booth

    Hi Jay,

    It is very generous of you to put make this class publicly available. Thank you. I’m about to use it.

    I noticed, however, that you did not include a method to destroy the class. I’m wondering if you just create it and leave it running.

    If I have the time, I’ll write a destroy method because I’d like to reclaim the memory and, especially the processor cycles, after a user has finished sending a note.

    What do you think?

    Don Booth,

  104. 104 Sebastian Fritzsche


    I think so too, Don Booth. I’m also just trying to find out steps of the class where I can see that the formular was sent successfully and then hide the form again. Otherwise users will be able to sent out lots of mails after and after.

    Jay, I love this class! Its great! Thank you for making it available!

  105. 105 giada

    is this contactform saved for spam?

  106. 106 David Watts

    Hi Dabe,

    It seems like flash is having trouble communicating with your php contact form. I suggest you check the links and the permissions on the file. You may also need to check if you are allowing script access.

    I hope that helps.


  107. 107 Jeff

    I am trying to go through and add some fields for address, phone, etc. but when i try to build, i get an error, everything looks good, and i haven’t changed any of the email settings. Thanks. If needed, I could e-mail the contactform.as file.

    C:\Users\Jeff\Desktop\AS3 Contact Form\ActionScript version\src\classes\com\warmforestflash\ContactForm.as, Line 31 1151: A conflict exists with definition _emailField in namespace internal.
    C:\Users\Jeff\Desktop\AS3 Contact Form\ActionScript version\src\classes\com\warmforestflash\ContactForm.as, Line 43 1151: A conflict exists with definition _emailTextField in namespace internal.
    C:\Users\Jeff\Desktop\AS3 Contact Form\ActionScript version\src\classes\com\warmforestflash\ContactForm.as, Line 86 1151: A conflict exists with definition emailWidth in namespace internal.

  108. 108 onedesign

    Thanks, very useful

  109. 109 Fernando

    This is what worked for me, I was able to make it work by including the phpmailer class along with the smtp class. You can do a google search for PHPMailer_v5.1 and you will get the files you need. You just need to put them in the same folder/directory as you contact_form.php. Here is my code for the contact_form.php:

  110. 110 Loop

    I have a problem with disappearing text. I don’t see any text in the textFields, nor can i type in them. I have copied the TextFont and SmallFont into my project and created another class Contact that uses it.


    package com.lup.contact{

    import flash.display.MovieClip;
    import com.warmforestflash.ContactForm;
    import flash.display.*;
    import flash.events.*;
    import flash.events.Event;

    public class Contact extends MovieClip{

    public var contactForm:ContactForm;

    public function Contact(mail:String){

    contactForm = new ContactForm();
    this.addEventListener(Event.ADDED_TO_STAGE, addedToStage);


    private function addedToStage(e:Event){

    // Label settings
    contactForm.nameText = “Nume”;
    contactForm.emailText = “E-mail”;
    contactForm.messageText = “Mesaj”;
    contactForm.sendButtonText = “TRIMITE”;
    contactForm.sendingText = “Se trimite mesajul…”;
    contactForm.errorEmailText = “E-mail invalid.”;
    contactForm.errorServerText = “Probleme de server.”;
    contactForm.confirmationText = “Mesajul a fost trimis. Va multumim!”;

    // Color settings
    contactForm.textColor = 0×000000;
    contactForm.borderColor = 0×222222;
    contactForm.backgroundColor = 0xffffff;
    contactForm.selectedBorderColor = 0x05b59a;
    contactForm.selectedBackgroundColor = 0×000000;
    contactForm.selectedBlurAmount = 50;
    contactForm.sendButtonTextColor = 0xffffff;
    contactForm.sendButtonTextRollOverColor = 0xffffff;
    contactForm.sendButtonColor = 0x05b59a;
    contactForm.sendButtonRollOverColor = 0xff4400;
    contactForm.errorColor = 0xff4400;
    contactForm.confirmationColor = 0x05b59a;

    // Layout settings
    contactForm.nameWidth = 400;
    contactForm.emailWidth = 400;
    contactForm.messageWidth = 550;
    contactForm.messageHeight = 200;
    contactForm.verticalSpacing = 10;




    I then instanciate the Contact class into my website.

    Do you know why i can’t see text?

    Thanks allot man! :D

  111. 111 Loop

    How can I adjust the .x and .y property of every object in the contactForm ( name, email, massage, and the submit button)

  112. 112 Dooby

    Hi Jay,

    Thanks so much for sharing your work, its a generous thing to do especially for free.
    However, I have a question..

    Am i right in thinking that to add the contact form to my contact page (or frame in my fla) I just need to add:

    import com.warmforestflash.ContactForm;
    var contactForm:ContactForm = new ContactForm();

    to that frame?

    Im still testing locally so I havent uploaded to my server yet.

    Currently im getting these errors
    1172: Definition com.warmforestflash:ContactForm could not be found.
    1172: Definition com.warmforestflash:ContactForm could not be found.
    1046: Type was not found or was not a compile-time constant: ContactForm.
    1180: Call to a possibly undefined method ContactForm.

    I have the content of the deploy folder in the same folder as my main fla, and the classes folder is there too.

    sorry, Im a complete newbie. Any help would be much appreciated and I’d be happy to offer beer tokens in exchange :)

    you can see my site here: http://s316631950.websitehome.co.uk/

    Many Thanks, Lester

  113. 113 Loop

    Hi, Jay.

    I have sorted it out. I have worked through your as3 code and modified some bits. Now i have another problem. On my host ( http://www.webfaction.com/ ) I have the site up and running. The problem is that when I sent a message it says “Message sent” but the mail has not been sent. I have checked the contact_form.php. My code is functional. Email is checked. But mail has not gone through.

    I don’t get a server error.

    Do you know what could be the problem?

  114. 114 Fabio

    Thanks for sharing your code. I changed a few things to match my layout (included a telephone field, changed the submit button) and everything worked fine.

  115. 115 Vladan

    Hi Jay,

    I’ve been working on flash website shishalica.com, and i’ve been useing your webform, that i adapted, it works well but i have some probleme with the php code. i know that you are not a php guru, but i hope you can help me out with this.

    This is error that i have :

    RangeError: Error #2006: L’index indiqué sort des limites.
    at flash.display::DisplayObjectContainer/getChildAt()
    at com.warmforestflash::ContactForm/validateForm()
    at com.warmforestflash::ContactForm/onSendButtonClick(

    and here is my php code :


    // Please specify your Mail Server – Example: mail.yourdomain.com.

    // Please specify an SMTP Number 25 and 8889 are valid SMTP Ports.

    // Please specify the return address to use
    ini_set('sendmail_from', 'milica@shishalica.com');

    echo"Error: No email address found";
    $senderName = $_POST['senderName'];
    $senderEmail = $_POST['senderEmail'];
    $senderPhone = $_POST['senderPhone'];
    $senderMessage = nl2br($_POST['senderMessage']);
    $headers = "MIME-Version: 1.0\r\n";
    $headers .= "Content-type: text/html; charset=iso-8859-1\r\n";

    // 1) Edit the first line below to match your email address
    $headers .= "From: milica@shishalica.com \n”;
    $headers .= “Reply-To: ” . $senderEmail;

    // 2) Then edit the following two lines to match your site name and email address
    $siteName = “http://www.shishalica.com”;
    $to = “milica@shishalica.com”;

    $toSubject = “Message from $senderName via $siteName”;
    $emailBody = “From: $senderName
    Email: $senderEmail
    Phone: $senderPhone
    $message = $emailBody;
    $ok = mail($to, $toSubject, $message, $headers);
    echo “returnValue=1″;
    echo “returnValue=0″;

    Can you please check it up and see what’s wrong…!!!

    Thank you in advance and thank you for this good webform!

    With my best regards,


  116. 116 flashes

    Nice form

  117. 117 jimbo


    how can I use diactric letters?

    thx in advance

  118. 118 jimbo

    i mean polish ones like ąśęółńćźż ĄŚĘÓŁĆŹŻ

    sorry for second post, but i can see previous is still in moderation, so maybe moderator merge them.

  119. 119 vasilev

    the form is great , but when i copy all of code to another fla file , and when publish it .. i cannot write in the fields . why ?

  120. 120 chris

    Finally, a form that actually works. Well done and thank you!

  121. 121 zak

    Thank you for sharing this nice contact form!
    Can you share the fla source of the XML version?


  122. 122 zak

    I have a little probleme with this contactForm:

    I have a button who switch between (fullscreen) and (normal mode) and when I am in fullscreen mode the contactform doesn’t work!

    Here is the code for the fullscreen :
    function fullscr(evt:MouseEvent) {


    And the code to return to normal mode:

    function normalm(evt:MouseEvent) {


    Can u help me to resolve this problem.
    Thank’s again!!

  123. 123 werner

    Hi.. thanks for this great template. However I am having the following problems and hope you can help me.

    1. When I open your flash file in Flash CS5 it open fine.. but I can’t see the static text areas so I can change like Name to be translated into spanish.. the actual form on stage is blank. How do I make it appear so I can change some of the words?.. then if I can do this it will publish in spanish. The reason why I would like to see it is also I would like to change the size of the form and maybe remove the message section so people can subscribe to our newsletter.

    2. The second thing is that I published and changed the settings in the instructions and put the SWF file into my html file in dreamweaver then uploaded the folder with all the contact form files that you mentioned… It shows up fine in my site and I can type and all.. but when I click to send… it keeps saying sending and never does send anything.. just keeps saying sending. Please help.

  124. 124 dougn

    Hi, for some reason when I publish my flash file, it comes out to around 125k. But in your download, the file was only 45k… why is your file so much smaller?

  125. 125 Wiyono

    Can you tell me how to put in Gaia Framework?

    Thank you

  126. 126 mohammad

    please help me how i can post value in php file

  127. 127 Maldito

    Hey Jay :)

    1st of all, big up for sharing your code, it’s easy to get even for an as3 beginner (such as myself), yet efficient and easy to customize. I’m finishin my 1st resume-portfolio flash website, and thanks to your contact form it’s almost done now. One thing is, I still can’t get my server to send me the mails!! I’ve been through the several posts from people who got the same issue, tried their code, adapted mine, but still, fail. Just wondering if since the last post, someone may have found out what’s the big deal about it? I also contacted my server, see what they say. Anyway, I know you can’t do much about the server-side thing, but hey, costs nothing to ask :p

    Keep up your work, it’s real good.


  128. 128 Maldito

    Hey there, problem solved.
    For people using a mail software (such as mail on osX), be sure to actually check your spam folder on the webpage…. LOL

    Just in case it might help someone, here’s my code, and it’s working properly: Be sure to keep it the way it is set right now, I had a hell of a night just because I did a quick copy/paste without noticing the change in the structure.

    echo"Error: No email address found";
    $senderName = $_POST['senderName'];
    $senderEmail = $_POST['senderEmail'];
    $senderMessage = nl2br($_POST['senderMessage']);
    $headers = "MIME-Version: 1.0\r\n";
    $headers .= "Content-type: text/html; charset=iso-8859-1\r\n";

    // 1) Edit the first line below to match your email address
    $headers .= "From: medi.p.lm@gmail.com \n”;
    $headers .= “Reply-To: ” . $senderEmail . “\n\n”;

    // 2) Then edit the following two lines to match your site name and email address
    $siteName = “www.4-9-13.com”;
    $to = “medi.p.lm@gmail.com”;

    $toSubject = “Message from $senderName via $siteName”;
    $emailBody = “From: $senderName
    Email: $senderEmail
    $message = $emailBody;
    $ok = mail($to, $toSubject, $message, $headers);
    echo “returnValue=1″;
    echo “returnValue=0″;

  129. 129 Jake

    Hey, I sure do appreciate the script! I’m having one slight problem. The code seems to be working fine through all aspects except when i get to the output. On the Flash output tab, it shows this error and I’m not sure how to fix it.

    ArgumentError: Error #2004: One of the parameters is invalid.
    at flash.display::Graphics/drawRect()
    at com.warmforestflash::ContactForm/createContactForm()
    at com.warmforestflash::ContactForm/init()
    at com.warmforestflash::ContactForm/onAddedToStage()
    at flash.display::DisplayObjectContainer/addChild()
    at contact/frame28()

  130. 130 Gabriel

    Thank you for the nice piece of code. Easy to set up, however I found a more advanced piece of kit, the Contact Form FX, given for free by the guys at http://www.flashxml.net/contact-form.html
    It is fully customizable through a couple of XML files, including what text fields to have, what colors to use, and all this without opening my Adobe Flash CS.
    Really recommend you guys give this a look, as it’s working great for me.


  131. 131 Steve

    Hi there and nice form.

    However, i tried to put this form on my website but i stumbled across some problems there. my root folder (where my .fla file lies) already contains a folder named “com” from tweenLite of greensock. I always get the error that “Definition com.warmforesflash:ContactForm could not be found.

    Any suggestions?


  132. 132 Steve

    Already solved the folder problem but now, after taking the steps Twang posted some Posts above, the text is completlely gone in the text fields and in the error message….

  133. 133 Vicu84

    Hello guys

    I just uploaded the deploy folder into my server ( i use hostgator) and form doesn’t send the message to email i set up inside the php…

    When i test the form , it has the status “Sending ” but it doesn’t send ….

    Please advice what to do .. i changed all like in the help file

    thank you much

  134. 134 Arioman

    hi , thanks for share this nice Form

    but i have problem , the message : Message sent. Thanks! appeared but when i check email i don’t get any email !!

    i set email like this :

    $headers .= “From: mymail@gmail.com \n”;

    $siteName = “mysite.com”;
    $to = “mymail@gmail.com”;

    or not different to use : mymail@mysite.com

    on both case the success message appeared and no message received at all

  1. 1 CSS Brigit | Flash AS3 Contact Form Using PHP
  2. 2 Contact Forms « Advanced Flash
  3. 3 20+ Php Contact Us Forms - Php Tutorials
  4. 4 Anonymous

Leave a Reply