A Flash Developer Resource Site

Results 1 to 3 of 3

Thread: Problem with Contact Form AS3

  1. #1
    Junior Member
    Join Date
    Sep 2010

    Problem with Contact Form AS3


    I'm trying to create a contact form, using a small PHP script.
    The PHP is working fine, the problem is in the AS.
    For some reason, I can't get the ActionScript to gather the information from all the fields in the contact form.

    For the last two fields, I get the error "Implicit coercion of a value of type String to an unrelated type Number."

    Here's the relevant part of the code:

    var email_data:String = "name=" + name_txt.text
    + "&email=" + email_txt.text
    + "&place=" + place_txt.text
    + "&day=" + day_txt.text;
    + "&time=" + time_txt.text;
    + "&message=" + message_txt.text;

    All of the fields exist as input text fields on the Stage - anyone have an idea why there's a problem with the time_txt and message_txt fields?

    Appreciate the help...

  2. #2
    Join Date
    May 2004
    you have semicolons in the middle of your concatenation...

    you can't do this:

    PHP Code:
    var str:String "hi";
    str would be equal to "hi" since the line terminates on the semicolon. the + "there"; part would error out.

    you can either jam it all together on one line with no semis:

    PHP Code:
    var email_data:String "name=" name_txt.text "&email=" email_txt.text "&place=" place_txt.text "&day=" day_txt.text "&time=" time_txt.text "&message=" message_txt.text
    or concatenate it on different lines...

    PHP Code:
    var email_data:String "name=" name_txt.text;
    email_data += "&email=" email_txt.text;
    email_data += "&place=" place_txt.text;
    email_data += "&day=" day_txt.text;
    email_data += "&time=" time_txt.text;
    email_data += "&message=" message_txt.text

  3. #3
    Junior Member
    Join Date
    Sep 2010
    That worked!

    Thanks a lot!

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Click Here to Expand Forum to Full Width

HTML5 Development Center