I have looked at the help files, and in many books I have but cannot find a good answer.
I am setting up a form that will be sent from a Flash site to the owner of the site via email. The form has a few user input text boxes set with variables that get put into the body of the email. That all works just fine. I want to add a check box with a label so that one could sign up for a newsletter. I have no problem dragging out the check box, but cannot find out how to turn the results of the check box into a variable to be inserted into the email. A simple true / false result would be fine. Any help?
Thanks in advance,
Jeff
Here is the code I have so far...
var variables2:URLVariables = new URLVariables();
var mailAddress2:URLRequest = new URLRequest("http://www.blahblah.com/email2.php");
comment_btn.addEventListener(MouseEvent.CLICK, onSubmit2);
function onSubmit2(e:Event):void
{
variables2.sName2 = name_txt.text;
variables2.sEmail2 = "fake@mchsi.com";
variables2.sSubject2 = "Comment from Website";
variables2.sMessage2 = email_txt.text + "\n\n" + phone_txt.text +"\n\n" + comment_txt.text;
mailAddress2.data = variables2;
mailAddress2.method = URLRequestMethod.POST;
sendToURL(mailAddress2);
feedback2_txt.text="Your comments have been received."
}
Assuming you are using the fl.controls.CheckBox component, your instance of the component will have a 'selected' property which is a Boolean (true / false.
So just name your instance of the component so you can access it in your Actionscript and use its 'selected' property:
variables2.checkBoxResult2 = myCheckBox.selected;
For more info on the CheckBox class go to:
Thanks for your input, but I am just learning action script and the Adobe page does nothing for me. I named my instance cbNewsletter, and placed the line of code that you suggested, changing it to:
variables2.checkBoxResult2 = cbNewsletter.selected
It gave me an error back for an undefined variable:checkBoxResult2.
Any other suggestions?
Thanks,
Jeff
Try putting in a trace or two to see where your problem is. Something like this:
trace("cbNewsletter.selected = " + cbNewsletter.selected);
variables2.checkBoxResult2 = cbNewsletter.selected;
trace("variables2.checkBoxResult2 = " + variables2.checkBoxResult2);
If that line of code is working, your output should show something like this:
cbNewsletter.selected = true
variables2.checkBoxResult2 = true
If it's not working, the code will break before you get to the second trace, so you will get the output from the first one and then your error message. You can also try testing your movie with 'Debug Movie' under the Debug tab instead of 'Test Movie' under the Control tab. If you do this then when you recieve an error the output will give you a line number where the error occured.
Without seeing the exact chunk of code where your error occured it is difficult to help you out anymore than that. For instance i don't know whether the error is occuring when you try to set checkBoxResult2 or when you try to retrieve it.
North America
Europe, Middle East and Africa
Asia Pacific