|
|
||||||||
| Ultrashock Tutorials > Flash MX 2004 > Flash MX 2004 UI Components | ||||||||
|
||||||||
|
|
Flash MX 2004 UI Components |
|
||||||
05. Radio ButtonsUnlike checkboxes, where you are allowed to select more than one for a given question in a form, you can only select one radio button from a radio button group. With radio buttons, the concept of a group is central to their use. They are used when a question requires a single answer (a "Select one of the following" type question.) As with checkboxes, it is definitely possible to give radio buttons an active behavior by listening for the click event and I won't go into that here since it was discussed in detail for checkboxes in the previous section and the technique is the same. Instead, the example below will show you how to set up a form with radio buttons and passively inspect them when the user submits the form. The structure of the example is closely related to that of the Checkbox component example, above.
If you have been following along from the Checkbox component, you will notice that the code in the submitButtonListener's click handler is much simpler for the Radio Button example. For one thing, you don't have to search in the form to find the correct components and then query them for their status. Instead, you can simply ask the radio button group to return a reference to the selected radio button. You created the radio button group by setting the groupName properties of the radio buttons in the Property Inspector in steps 2 to 5. Once you have the reference to the selected Radio Button component, you can easily get its label and compose and display a message within the TextArea component stating the user's selection.
|
||||||||
©2003 Ultrashock.com - All rights reserved |