Flash CS3 Documentation |
|||
| ActionScript 2.0 Components Language Reference > RadioButton component > RadioButton.groupName | |||
Flash Player 6 (6.0.79.0).
Flash MX 2004.
radioButtonInstance.groupNameradioButtonGroup.groupName
Property; sets the group name for a radio button instance or group. You can use this property to get or set a group name for a radio button instance or for a radio button group. Calling this method overrides the groupName parameter value set during authoring. The default value is "radioGroup".
The following example sets the group name for a group of three radio buttons to myrbGroup. It positions the buttons and then creates a listener for a click event on the radio button group. When the user clicks a radio button, the example displays the groupName property for the button that was clicked.
You first drag a RadioButton component from the Components panel to the current document's library, and then add the following code to Frame 1 of the main timeline:
/**
Requires:
- RadioButton component in library
*/
import mx.controls.RadioButton;
this.createClassObject(RadioButton, "first_rb", 10, {label:"first", groupName:"myrbGroup"});
this.createClassObject(RadioButton, "second_rb", 20, {label:"second", groupName:"myrbGroup"});
this.createClassObject(RadioButton, "third_rb", 30, {label:"third", groupName:"myrbGroup"});
// Position radio buttons on Stage.
second_rb.move(0, first_rb.y + first_rb.height);
third_rb.move(0, second_rb.y + second_rb.height);
// Create listener object.
var rbListener:Object = new Object();
rbListener.click = function(evt_obj:Object){
trace("The selected radio button group name is " + evt_obj.target.groupName);
}
// Add listener.
myrbGroup.addEventListener("click", rbListener);
Flash CS3
Send me an e-mail when comments are added to this page | Comment Report
Current page: http://livedocs.adobe.com/flash/9.0/main/00003388.html