Skip navigation
Brewha8
Currently Being Moderated

CheckBox question

Oct 6, 2010 2:19 PM

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."
   
}

 
Replies
  • Currently Being Moderated
    Oct 6, 2010 5:06 PM   in reply to Brewha8

    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:

     

    http://help.adobe.com/en_US/FlashPlatform/reference/actionscript/3/fl/ controls/CheckBox.html#methodSummary

     
    |
    Mark as:
  • Currently Being Moderated
    Oct 8, 2010 11:14 AM   in reply to Brewha8

    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.

     
    |
    Mark as:

More Like This

  • Retrieving data ...

Bookmarked By (0)

Answers + Points = Status

  • 10 points awarded for Correct Answers
  • 5 points awarded for Helpful Answers
  • 10,000+ points
  • 1,001-10,000 points
  • 501-1,000 points
  • 5-500 points