Skip to main content
December 11, 2015
Question

How to create button group like RadioButton group?

  • December 11, 2015
  • 1 reply
  • 361 views

Hi. I was trying to create button group as in the radio button group function. I've changed few things to fit the condition as button.

But the errors I got are :

Scene 1, Layer 'Actions', Frame 2, Line 19    1119: Access of possibly undefined property selection through a reference with static type fl.controls:Button.

Scene 1, Layer 'Actions', Frame 2, Line 14    1119: Access of possibly undefined property group through a reference with static type flash.display:SimpleButton.

Anyone can help me? Thank you.

Here is my coding

//using the import directive to import the required class

//import fl.controls.RadioButtonGroup;

import flash.events.MouseEvent;

import flash.events.TimerEvent;

import flash.utils.Timer;

import fl.controls.Button;

import flashx.textLayout.events.ModelChange;

//starting out with a score of 0

var myscore = 0; score.text = myscore+"";

//creating a new instances for RadioButtonGroup Class

var mygroup1:Button = new Button("group1");

q1a.group = q1b.group = q1c.group = q1d.group = mygroup1;

next1.addEventListener(MouseEvent.CLICK, quizHandler1)

function quizHandler1 (event:MouseEvent):void

{

    if(mygroup1.selection == "q1c")

    {

        myscore+=2; nextFrame();

        //correct.visible = true;

    }

   

    else

    {

        nextFrame();

        //correct.visible = false;

    }

}

myTimer.start();*/

var endTime:int = getTimer();

endTime += 40*60*1000;  //adjust endTime to 15 minutes in the future.

var countdownTimer:Timer = new Timer(1000);

countdownTimer.addEventListener(TimerEvent.TIMER, updateTime);

countdownTimer.start();

function updateTime(e:TimerEvent):void

{

  var timeLeft:Number = endTime - getTimer();

  var seconds:Number = Math.floor(timeLeft / 1000);

  var minutes:Number = Math.floor(seconds / 60);

  seconds %= 60;

  minutes %= 60;

  var sec:String = seconds.toString();

  var min:String = minutes.toString();

  if (sec.length < 2) {

    sec = "0" + sec;

  }

  if (min.length < 2) {

    min = "0" + min;

  }

  var time:String = min + ":" + sec;

  timer.text = time;

}

This topic has been closed for replies.

1 reply

kglad
Community Expert
Community Expert
December 11, 2015

if you're trying to create a radiobutton instance use,

var rb:RadioButton=new RadioButton();

if you're trying to create button component instances use the Button() constructor.

and if you're trying to create simple buttons, use the SimpleButton() constructor.

none of then accept an argument and only the radiobutton instance has native group and groupName support.