A Flash Developer Resource Site

Results 1 to 7 of 7

Thread: [CS3] Email Form Sends Even if Fields are Empty

  1. #1
    Nose Picker
    Join Date
    May 2002
    Posts
    66

    [CS3] Email Form Sends Even if Fields are Empty

    I'm making a simple PHP based email form that worked fine in Flash MX. I'm exporting as Flash 8 and authoring in Flash CS3.

    Right now I have this AS2.0 in the first frame and it works fine:

    Code:
    stop();
    function lineAdapt() {
    	message_send = message;
    	while (msg_count<length(message)) {
    		msg_count = msg_count+1;
    		if ((substring(message_send, msg_count, 2)) eq "\r") {
    			message_send = (substring(message_send, 1, msg_count-2)) + "\n" + (substring(message_send, msg_count+2, (length(message_send))-msg_count+2));
    		}
    	}
    	message = message_send;
    	delete msg_count;
    	delete message_send;
    }
    Then for my button I have:
    Code:
    on (release) {
    	if (from eq "" || subject eq "" || body eq "") {
    		gotoAndPlay(3);
    	} else {
    		lineAdapt();
    		loadVariablesNum("mail.php", 1, "POST");
    		gotoAndPlay(5);
    	}
    }
    Naturally my input fields variable names are set to those in the button AS. But whether the fields are full or empty the message sends. The only way to get this to work is if I name each field in both the variables and the instance name, but if I do that each field has this text in it when the form comes up:

    _level0.instance8.from
    _level0.instance8.subject
    _level0.instance8.body

    Anyone see what's going wrong? Like I said, this worked in Flash MX just fine.

  2. #2
    Senior Member
    Join Date
    Aug 2000
    Location
    Montréal
    Posts
    14,141
    change eq for ==
    eq dates from flash 4
    gparis

  3. #3
    Nose Picker
    Join Date
    May 2002
    Posts
    66
    Thanks for the reply. Changed the eq to == but no dice. It still sends with empty fields. Driving me nuts.

  4. #4
    Senior Member
    Join Date
    Aug 2000
    Location
    Montréal
    Posts
    14,141
    you'll need to declare them as empty to start with:

    var from:String = "";
    var subject:String = "";

    etc.

    then you can see if they are as they were declared.

    gparis

  5. #5
    Nose Picker
    Join Date
    May 2002
    Posts
    66
    Where would I insert those declarations?

  6. #6
    Nose Picker
    Join Date
    May 2002
    Posts
    66
    Ok, I stuck those lines in a separate frame at the beginning of my timeline and it worked like a charm! Thanks for the help!

  7. #7
    Senior Member
    Join Date
    Aug 2000
    Location
    Montréal
    Posts
    14,141
    Good for you!

    The 2 main differences between player 6 (MX) and above are:
    - all variables must be declared before use
    - as is case sensitive: myVar and myvar are 2 different variables.

    gparis

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