0 Replies Latest reply on Sep 27, 2010 7:50 AM by Chuckle12345

    Referencing Functions from within onChange() event handler

    Chuckle12345

      I am trying to reference a function from within the onChange event handler to no avail.  I am using a checkbox column within a datagrid to alter another control's appearance.  I am using the CheckBox onChange() event handler to initiate the change in appearance.  I understand that it is probably a scope issue limiting me from referencing the DisableChartingDataset() function.  I tried to reference the ChartControl directly within OnChange function but could not; unknown object error.  I also tried to call the DisableChartingDataset() directly in Checkbox definition to no avail.  I am new to Flex programing so I may not be utilizing the best approach to tackle this problem.  I would appreciate any help.  I will list my source configuration below.

       

       

      <fx:Script>
              <![CDATA[

       

                  protected function DisableChartingDataSet(selected:Boolean):void
                  {
                      var index:int = myGrid.selectedIndex;

       

                      var item:String = myGrid.selectedItem.Observation;
                     
                      myStockChart.dataSets[index].compared = selected;
                  }

       

              ]]>

      </fx:Script>

       

       

              <mx:DataGrid id="myGrid" width="100%" height="200" >
                  <mx:columns>
                      <mx:DataGridColumn headerText="" width="30" dataField="Selected" editable="true" >
                          <mx:itemRenderer>
                              <fx:Component>
                                  <mx:CheckBox label="{data.Observation}" textAlign="center" change="onChange(event);" selected="{(data.Selected == 'true')?true:false}" click="{data.Selected = (data.Selected != 'true') ? 'true' : 'false';}" >

       

                                      <fx:Script>
                                          <![CDATA[
                                              import mx.controls.Alert;
                                             
                                              private function onChange(evt:Event):void
                                              {
                                                  Alert.show(data.Observation + " clicked.");

       

                                                 DisableChartingDataSet(data.Selected);
                                              }
                                          ]]>
                                      </fx:Script>
                                  </mx:CheckBox>
                              </fx:Component>
                          </mx:itemRenderer>
                      </mx:DataGridColumn>               
                  </mx:columns>
              </mx:DataGrid>

       

       

      ce