Ursula
Ursula

Reputation: 21

Use actionscript to uncheck a checkbox in a component?

I have a component with checkboxes, the checkboxes are bound to booleans in the main code:

<mx:CheckBox id="LyrClearAll" selected="{Application.application.bLyrClearAll}"/>  

This works fine for the checkboxes that don’t change unless a user interacts with them again. My problem appears because I want to “uncheck” one of the boxes everytime the component is closed. (I know something other than a checkbox would work better, but I’m trying to keep things consistent in this component.)

I have tried setting the bound Boolean variable to false, and I’ve tried setting the checkbox.selected value to false. Neither are working, everytime I open the component the checkbox is still checked.

private function makeLyrsPopUp(evt:MouseEvent):void  
{  
  var panelLyr:popUpLayers = PopUpManager.createPopUp(this, popUpLayers, false) as popUpLayers;    
  panelLyr.LyrClearAll.selected == false; //?? set checkbox back to unchecked 
  panelLyr["cancelButton"].addEventListener("click", removeMe);
  panelLyr["okButton"].addEventListener("click", submitData);
  PopUpManager.centerPopUp(panelLyr);

  function submitData(event:Event):void  //change layer visibility based on check boxes in popupLayer
  {
    bLyrStreet = panelLyr.LyrStreet.selected;
    bLyrParcel = panelLyr.LyrParcel.selected;
    bLyrClearAll = panelLyr.LyrClearAll.selected;
    if (bLyrClearAll)
    {
      clearLayers();
      bLyrClearAll == false;  //?? set checkbox back to unchecked
    } 
    removeMe(event);
  }
} 

Upvotes: 0

Views: 2265

Answers (2)

Ursula
Ursula

Reputation: 21

Needed to change == false to = false

Upvotes: 2

splash
splash

Reputation: 13327

bLyrClearAll should be declared bindable:

[Bindable]
var bLyrClearAll: Boolean;

Upvotes: 1

Related Questions