3 Replies Latest reply on Apr 28, 2009 11:27 PM by ntsiii

    CheckBox and Alert

    GeorgeWS Level 1

      I must be the dumbest but...

       

      I have a checkbox.

       

      <mx:checkbox id="repLabel" Label="Rep" selected="{selectedItem.salesrep}" />

       

      I then want an Alert to pop up showing if its checked or not.

       

      Alert.show(repLabel.selected)

       

      All I get is an error while compiling that says Implicit coercion of a value of type Boolean to an unrelated type String

       

      I am stumped on how to just show true or false.

       

      Thanks

      George

        • 1. Re: CheckBox and Alert
          _Natasha_ Level 4

          Hi George,

           

          this showld works:

          Alert.show(repLabel.selected.toString())

          repLabel.selected is a Boolean, you showld convert it to string. trace works fine with all types.

          • 2. Re: CheckBox and Alert
            run,ryan! Level 3

            selected of check box indicates whether a toggle button is toggled    on (true) or off (false).

            when you assign it a value that's not boolean, it's casted to blooean automatically.

            so you should use other properties other than selected, maybe name

            <mx:checkbox id="repLabel" Label="Rep" name="{selectedItem.salesrep}" />
            Alert.show(repLabel.name)
            
            • 3. Re: CheckBox and Alert
              ntsiii Level 3

              And if you had done:

              Alert.show("repLabel.selected=" + repLabel.selected);

               

              That would have worked because the string concatenation causes an implicit toString().

               

              Tracy Spratt