Look to see if CheckBox supports the "valueCommitted" event.  That fires
when the selection is changed programmatically, but click and change only
fire on user interaction.

 

Be careful to check for nulls when using this event though.

 

Tracy Spratt,

Lariat Services, development services available

  _____  

From: flexcoders@yahoogroups.com [mailto:flexcod...@yahoogroups.com] On
Behalf Of secrit.service
Sent: Tuesday, March 17, 2009 2:09 PM
To: flexcoders@yahoogroups.com
Subject: [flexcoders] Checkbox issue

 

Hi all,

I have a checkbox (chkMyCheckbox) and added an eventlistener to it.

chkMyCheckbox.addEventListener(Event.CHANGE, checkBoxChangeHandler);

In the changeHandler I peform the necessary tasks :

private funtion checkBoxChangeHandler (evt:Event):void {
     if (chkMyCheckbox.selected) {
          lblMyLabel.text = "Checkbox marked";
     } else {
          lblMyLabel.text = "Checkbox unmarked";
    }
}

Suppose I have a button btnMyButton which, when clicked, changes the state
of my checkbox. In the mean time I also want the text of lblMyLabel to be
changed. I supposed I could write 

private function btnMyButtonClicked() {
   if (chkMyCheckbox.selected) {
          chkMyCheckbox.selected = false;
     } else {
          chkMyCheckbox.selected = true;
    }     
}

and by setting the state of the checkbox programmatically also the
checkBoxChangeHandler would be executed.
But this doesn't seem to work. How can i catch this event anyhow?

Thanks

 

 



Reply via email to