ProblemYou want to retrieve the value from a checkbox or a toggle button. SolutionUse the instance's selected property. DiscussionCheckboxes and buttons that toggle provide basically the same type of functional-itythey 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); |