Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 3630422
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 19, 20262026-05-19T00:16:05+00:00 2026-05-19T00:16:05+00:00

I have a checkbox in a component: <s:CheckBox id=myCB_1 /> In my main.mxml I

  • 0

I have a checkbox in a component:

<s:CheckBox id="myCB_1" />

In my main.mxml I need to test for the state of the checkbox. I originally had all my code in main.mxml, but it was getting really long, and I thought that it was better practice to break my code into components. Also, I have other projects where the same concept will apply, so I really want to figure this out.

I have the following function :

private function checkAlarms(currentTime:Date):void
{
    if (!breakfastAlarmSounded)
    {
        if ((currentTime.hours > breakfastTime.hours) || ((currentTime.hours == breakfastTime.hours) && (currentTime.minutes >= breakfastTime.minutes)))
        {
            if (myCB_1.selected)
            {
                playBreakfastAudioAlarm();
            }
            if (myCB_2.selected)
            {
                playBreakfastVisualAlarm();
            }

            breakfastAlarmSounded = true;
        }
    }
...

simply addressing the component, as in:

myComponent.myCB_1.selected

doesn’t work. Someone mentioned that I need to create a variable in my component that refers to the id (myCB_1) of checkbox, but I don’t really understand or know how to do that, and they didn’t elaborate.

How do I test for the status of the CheckBox “myCB_1” in the component from within my main.mxml?

many thanks,

Mark

(newbie)

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-19T00:16:05+00:00Added an answer on May 19, 2026 at 12:16 am

    With very little information, I’m going to suspect you originally had the CheckBox included in main.mxml and moved it to a custom component. If so, you need to address the CheckBox’s ID via the custom component’s ID. Something like this (from main.mxml):

    if(yourComponentsID.myCB_1.selected)
    {
        ...
    }
    

    If this isn’t the case, please edit your post and give us more detail.


    EDIT

    You said you created a new custom component and moved the CheckBox into it. Great, that’s a helpful start 🙂 When you included your new component in your main.mxml file, it should look something like this:

    <component:YourNewComponent />
    

    Of course, however you named it (and whichever namespace is used to reference it) will be different from my example, but the principle should still apply. In main.mxml, you need to give your custom component a unique ID string so you can reference it within main:

    <component:YourNewComponent id="myComponent" />
    

    From here on, you should be able to reference the component, and any public elements within it: myComponent.myCB_1.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I need to add a component like checkbox in listview with listitem. I have
I have a .NET application that contains a checkbox (System.Windows.Forms.Checkbox). This component (WindowsForms10.BUTTON.app.0.378734a1) is
I have a List component that has drop-in CheckBox itemEditor that also serves as
EDIT: This question was originally about checkboxes, but I am getting the same behavior
I have a checkbox group which works fine when you tick one but it
I need to implement a Checkbox tree and I came across this component called
I have a XBL component which creates a checkbox control in javascript. Value is
I have a checkbox list control on my asp.net web form that I am
I have a checkbox in GridViewColumn which i use for show/change database value. The
T have used checkbox column in gridview. On click of a linkbutton, it should

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.