View comments | RSS feed

RadioButtonGroup component

For information about the RadioButtonGroup class, see RadioButton component.


Version 8

Comments


No screen name said on Mar 23, 2006 at 2:38 AM :
In the RadioButton documentation, it seems like the RadioButtonGroup appears magically simply by writing a name for it. I don't know how this works when placing the component on stage manually, but when creating the radio buttons dynamically in actionscript, the following can be used:

import mx.controls.RadioButton;
import mx.controls.RadioButtonGroup;

movieclip.createClassObject(RadioButtonGroup, "answerGroup", depthHere);

//create radio buttons:
for(var i:Number = 0; i < noOfButtons; i++){
var altLabel =getButonLabel();
var altID = getButonID();
movieclip.createClassObject(RadioButton, "alt" + i, movieClip.getNextHighestDepth(), {label:altLabel, data:altID, groupName:"answerGroup"});
movieclip["alt"+i].move(10, 15*i);
}
// Create listener object.
var rbListener:Object = new Object();
rbListener.click = function(evt_obj:Object){
trace("The selected radio button is " + evt_obj.target.label);
}

//Add listener to RadioButtonGroup which can now be referenced:
movieclip.answerGroup.addEventListener("click", rbListener);
amandeepsiin said on Sep 9, 2006 at 3:57 AM :
This also works for the radio buttons manually placed in the fla file.

 

RSS feed | Send me an e-mail when comments are added to this page | Comment Report

Current page: http://livedocs.adobe.com/flash/8/main/00003931.html