April 2006
Beginner
544 pages
14h 51m
English
You want to retrieve the value from a checkbox or a toggle button.
Use the instance’s selected property.
Checkboxes and buttons that toggle provide basically the same type of functional-ity—they can be selected or deselected. Each of these two types of components has a property named selected that returns either true or false. In the case of a checkbox, the selected property is true if the checkbox is checked and false if it is unchecked. The button that toggles returns true if the button is pressed in and false otherwise. The following code retrieves the current state of a checkbox named cchOptIn and writes it to the Output panel when the listener object’s click( ) method gets called:
var oListener:Object = new Object();
oListener.click = function(oEvent:Object):Void {
trace(cchOptIn.selected);
};
cbtSubmit.addEventListener("click", oListener);Read now
Unlock full access