4 Replies Latest reply on Jul 19, 2010 1:09 PM by Fayena

    check to see if radiobutton and checkbox are both selected before displaying img problem

    Fayena

      It works except when silver is selected and I'm changing from chestnut to one of the other radio buttons.  The first time I select a radio button (other than chestnut) the silverimage will not be displayed but the second time I select one (other than chestnut) the silverimage WILL be displayed.   For example chestnut and silver are both checked (silverimage does not display which is correct) I then select bay (silver still checked) silverimage does not display which is wrong.  I then select black (silver still checked) silverimage displays.  It does not matter which order I select the other radios buttons.  The first one after chestnut will not display silver as it should.  Everything else works.   Any suggestions?   I'm new to flex so please be gentle, also if there is a better way to do this I'm open to suggestions.    Here is the code.  Thanks for the help!

       

       

       

       

      <fx:Script>

      <![CDATA[

       

      private function init():void {

      Silver.addEventListener(Event.CHANGE,

      checkBox_change);

      red.addEventListener(Event.CHANGE,checkBox_change);

      bay.addEventListener(Event.CHANGE,checkBox_change);

      seal.addEventListener(Event.CHANGE,checkBox_change);

      black.addEventListener(Event.CHANGE,checkBox_change);

      }

      private function checkBox_change(evt:Event):void {

      if (!red.selected && Silver.selected){

      silverimage.visible = true;

      }

      else{

      silverimage.visible = false;

      }

      }

      ]]>

      </fx:Script>

       

       

      <!-- Script ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -->

       

       

       

      <!-- Declarations ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -->

       

      <fx:Declarations>

      <s:RadioButtonGroup id="radiogroup1"/>

       

       

       

      </fx:Declarations>

       

      <!-- UI components ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -->

       

       

      <s:BorderContainer y="10" width="90%" height="100%" cornerRadius="11" borderWeight="3" textAlign="center" horizontalCenter="0">

      <s:Label text="Horse Generator"

      y="11"

      styleName="addHeader" fontFamily="Arial" fontSize="27" color="#55591C" horizontalCenter="0"/>

      <mx:Form y="126" cornerRadius="9" backgroundColor="#BDB5A9" right="185" >

      <s:RadioButton label="Chestnut" id="red" groupName="radiogroup1" selected="true" change="checkBox_change(event);"/>

      <s:RadioButton label="Bay" id="bay" groupName="radiogroup1"  change="checkBox_change(event);"/>

      <s:RadioButton label="Seal" id="seal" groupName="radiogroup1" change="checkBox_change(event);"/>

      <s:RadioButton label="Black" id="black" groupName="radiogroup1" change="checkBox_change(event);"/>

      <s:CheckBox id ="Champagne" label="Champagne"/>

      <s:CheckBox id = "Silver" label="Silver" change="checkBox_change(event);"/>

       

      </mx:Form>

      <mx:Image y="77" id="redimage" source="@Embed(source='images/red.png')" visible="{red.selected}" width="524" height="357" scaleContent="true" left="38"/>

      <mx:Image y="77" id="bayimage" source="@Embed(source='images/bay.png')" visible="{bay.selected}" width="524" height="357" scaleContent="true" left="38"/>

      <mx:Image y="77" id="sealimage" source="@Embed(source='images/seal.png')" visible="{seal.selected}" width="524" height="357" scaleContent="true" left="38"/>

      <mx:Image y="77" id="blackimage" source="@Embed(source='images/black.png')" visible="{black.selected}" width="524" height="357" scaleContent="true" left="38"/>

      <mx:Image y="77" id="champagneimage" source="@Embed(source='images/champagne.png')" visible="{Champagne.selected}" width="524" height="357" scaleContent="true" left="38"/>

      <mx:Image y="77" id="silverimage" source="@Embed(source='images/silver.png')"  visible="false" width="524" height="357" scaleContent="true" left="38" />

      </s:BorderContainer>