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 8542729
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T12:08:11+00:00 2026-06-11T12:08:11+00:00

Quick version: When trying to compare 2 RadioButtonGroups with an if statement, if one

  • 0

Quick version:

When trying to compare 2 RadioButtonGroups with an if statement, if one of the groups does not have a RadioButton selected, I get an error;

Error #1009: Cannot access a property or method of a null object reference.

Long version:

I am creating 2 lists in actionscript that have the same content and have stored them in RadioButtonGroups. The idea is that a user will choose an element from column A and then select an element from column B. This functionality works fine, but when I do validation where the program checks when clicking a button if both columns have been selected, I get:

Cannot access property error (See above).

Here is my code:

import fl.controls.RadioButtonGroup;
import flash.events.MouseEvent;
import flash.net.URLLoader;
import flash.net.URLRequest;
import flash.events.Event;
import fl.controls.RadioButton;

var focus1:RadioButtonGroup = new RadioButtonGroup("Focus 1");
var focus2:RadioButtonGroup = new RadioButtonGroup("Focus 2");
var myXML:XML;
var myLoader:URLLoader = new URLLoader();
var btn1:Array = new Array();
var btn2:Array = new Array();

myLoader.load(new URLRequest("courseLoader.xml"));
myLoader.addEventListener(Event.COMPLETE, processXML);

function processXML(e:Event):void {
    myXML = new XML(e.target.data);
    
    for (var i = 0; i < myXML.COURSES.length(); i++) {
        var radA:RadioButton = new RadioButton();
        var radB:RadioButton = new RadioButton();
        
            // Create left focus column
        radA.x = 50;
        radA.y = i * 25 + 75;
        radA.width = 300;
        radA.name = "radA" + i;
        radA.label = myXML.COURSES[i].NAME[0];
        addChild(radA);
            btn1.push(radA);
        btn1[i].group = focus1;
        
        // Create right focus column
        radB. x = 450;
        radB.y = i * 25 + 75;
        radB.width = 300;
        radB.name = "radB" + i;
        radB.label = myXML.COURSES[i].NAME[0];
        addChild(radB);
        btn2.push(radB);
        btn2[i].group = focus2;
}

submit_btn.addEventListener(MouseEvent.CLICK, checkResult);

function checkResult(e:MouseEvent):void {
    var tempVar 
    
    if (focus1.selection.label == focus2.selection.label) {
        feedback.text = "Nope, they're both the same. Try again";
    } /* THIS IS WHERE IT STOPS WORKING */ else if (focus1.selection == null) {
        feedback.text = "You forgot to choose a focus from the 2nd column!";
    } else if (focus1.selection.label == null) {
        feedback.text = "You forgot to choose a focus from the 1st column!";
    } else if (focus2.selection.label == null) {
        feedback.text = "You forgot to choose a focuse from the 2nd column!";
    }
}

I’ve tried using different kinds of properties and methods for comparing both groups and checking if one of them is not selected but I keep getting the same error.

  • 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-06-11T12:08:12+00:00Added an answer on June 11, 2026 at 12:08 pm

    You first are checking for labels, and only THEN you check if selection is null. This is wrong, you have to do it in reverse order.

    if (focus1.selection == null) {
        feedback.text = "You forgot to choose a focus from the 1st column!";
    } else if (focus2.selection == null) {
        feedback.text = "You forgot to choose a focus from the 2nd column!";
    } else if (focus1.selection.label == focus2.selection.label) {
        feedback.text = "Nope, they're both the same. Try again";
    } 
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

What's a quick way to detect Facebook API version at runtime? I'm not trying
Quick version: How do I get an image that was generated on the users
Just a quick questions.. I have made an outlook add-in for 2007 version and
Quick method description: I have two tables, lets name them table ONE and table
That is a quick question: Where can I get PHP's runkit extension for version
Quick version (for those familiar with Mongoid & Sinatra ) : If it's not
So I have a quick mockup here of what I am trying to do
I'm trying to create a quick ASP.NET MVC 3 application using the RC version
I have some SQL that does an order by case statement. It works fine.
Quick version of my question: Is the only time you need to use lock

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.