A Flash Developer Resource Site

Results 1 to 5 of 5

Thread: Can't get value of checkbox component - why?

  1. #1
    Member
    Join Date
    Jan 2001
    Posts
    54

    Can't get value of checkbox component - why?

    This is so simple yet it's making me crazy. I'm simply trying to get the value of a component checkbox with the instance name of "check1".

    I have one line of actionscript that reads:
    Code:
    check1_value = check1.getValue();
    Shouldn't this assign the true/false value to the "check1_value" variable? Why doesn't it work?
    Last edited by Danger Madcow; 07-26-2004 at 06:43 PM.

  2. #2
    Registered User nunomira's Avatar
    Join Date
    May 2002
    Location
    portugal
    Posts
    7,003
    hi,

    You don't mention the version you're using, but in MX 2004, you use the selected property:
    code:

    check1.selected


  3. #3
    Member
    Join Date
    Jan 2001
    Posts
    54
    I am using MX 2004. Setting the code to:
    Code:
    check1_value = check1.selected;
    does indeed return true or false, but only the initial true/false value. How would I set this up so that toggling the checkbox would auto-update the variable?

  4. #4
    Registered User nunomira's Avatar
    Join Date
    May 2002
    Location
    portugal
    Posts
    7,003
    Look in your reference!
    code:

    myListener = new Object();
    myListener.click = function(eventObj)
    {
    trace("The selected property has changed to " + eventObj.target.selected);
    };
    check1.addEventListener("click", myListener);


  5. #5
    Member
    Join Date
    Jan 2001
    Posts
    54
    I always forget to RTFM. Thanks for your help - it worked perfectly.

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