F > FRadioButton.setChangeHandler |
![]() ![]() ![]() |
FRadioButton.setChangeHandler
Availability
Flash Player 6.
Usage
myRadioButton
.setChangeHandler
(functionName,
[
location
]
)myRadioButtonGroup
.setChangeHandler
(functionName,
[
location
]
)
Parameters
functionName
A string specifying the name of the handler function to execute when the value of a radio button changes. If the location
parameter is not specified, this function must be in the same Timeline as the component instance.
location
A reference to a data object, movie clip, or Timeline that contains the specified function. This parameter is optional and defaults to the parent Timeline of the component.
Returns
Nothing.
Description
Method; specifies a change handler function to call when the radio button selection changes. You can specify the same change handler function for more than one component; the function always accepts the instance of the component that has changed as a parameter. Calling this method overrides the Change Handler parameter value specified in authoring.
Usage 1: Specifies the function to call if the radio button instance myRadioButton
is selected or deselected.
Usage 2: Specifies the function to call if the selected radio button in the group radioButtonGroup
changes. Specifying a function for a group of radio buttons is the equivalent of specifying the same function for all the radio buttons in that group individually with myRadioButton
.setChangeHandler
.
For more information, see Writing change handler functions for components in the Using Components chapter of Using Flash.
Example
Usage 1: The following code specifies myHandler
as the function called when radio1
is selected.
radio1.setChangeHandler
("myHandler
");
Usage 2: The following code specifies onChange as the function called when a radio button in the group radioGroup1
is selected.
radioGroup1.setChangeHandler
("onChange");
The following code specifies onChange
as the function called when the user selects a radio button in radioGroup1
. Because the location
parameter is not specified, onChange
must be in the same Timeline as the component instance. The component
parameter in onChange
is automatically set with the component (the component that has changed as the result of user input and that specifies onChange
as its change handler)in this case, a radio button in the group. The actions defined in onChange
specify that when the user selects a radio button, the instance name is written to the Output window.
radioGroup1
.setChangeHandler("onChange"); function onChange(component
){ trace(component
._name); }
If in the preceding example onChange
is a function located in the great-grandparent Timeline of the component's Timeline, the first line of code would be as follows:
radioGroup1
.setChangeHandler("onChange", _parent._parent._parent);
The following code creates the function onChange
in an instance of myObject
(which is of class Object), and then specifies onChange
as the function for radioGroup1
.
myObject = new Object(); myObject.onChange = function(component){ trace(component
._name); }radioGroup1
.setChangeHandler("onChange", myObject);
![]() ![]() ![]() |