MACROMEDIA FLASH 8-COMPONENTS LANGUAGE Reference page 1040

Components language reference
Table of Contents

Advertisement

The second usage example uses an
RadioButton instance. The keyword
component, refers to the component instance. For example, the following code, attached to
the radio button
myRadioButton
on (click) {
trace(this);
}
Example
The following example creates three radio buttons, positions them on the Stage, and creates a
listener for the click event. When a user clicks one of the three radio buttons, the listener
displays the instance name of the selected radio button.
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:"radioGroup"});
this.createClassObject(RadioButton, "second_rb", 20, {label:"second",
groupName:"radioGroup"});
this.createClassObject(RadioButton, "third_rb", 30, {label:"third",
groupName:"radioGroup"});
// Position RadioButtons 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 instance is " + evt_obj.target.selection);
}
// Add listener.
radioGroup.addEventListener("click", rbListener);
1036
RadioButton component
handler and must be attached directly to a
on()
, used inside an
this
, sends "_level0.myRadioButton" to the Output panel:
handler attached to a
on()

Hide quick links:

Advertisement

Table of Contents
loading

This manual is also suitable for:

Flash 8

Table of Contents