0 Replies Latest reply on Jan 29, 2010 11:03 AM by edwinmerced

    Clicking inside a windows is making a state change. why?

    edwinmerced Level 1

      I have the following:

       

      <?xml version="1.0" encoding="utf-8"?>
      <mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" layout="absolute" creationComplete="init()" viewSourceURL="srcview/index.html">
         <mx:states>
            <mx:State name="GraphState">
               <mx:RemoveChild target="{DataWindow}"/>
            </mx:State>
                  <mx:State name="DataState">
               <mx:RemoveChild target="{GraphWindow}"/>
            </mx:State>
         </mx:states>
         <mx:Model id="custdata">
            <months>
               <month>
                  <name>Jan</name>
                  <monthdata>98</monthdata>
               </month>
               <month>
                  <name>Feb</name>
                  <monthdata>89</monthdata>
               </month>
               <month>
                  <name>Mar</name>
                  <monthdata>67</monthdata>
               </month>
               <month>
                  <name>Apr</name>
                  <monthdata>56</monthdata>
               </month> 
               <month>
                  <name>May</name>
                  <monthdata>90</monthdata>
               </month> 
               <month>
                  <name>Jun</name>
                  <monthdata>34</monthdata>
               </month>
               <month>
                  <name>Jul</name>
                  <monthdata>78</monthdata>
               </month>
               <month>
                  <name>Aug</name>
                  <monthdata>89</monthdata>
               </month>
               <month>
                  <name>Sep</name>
                  <monthdata>98</monthdata>
               </month>
               <month>
                  <name>Oct</name>
                  <monthdata>34</monthdata>
               </month> 
               <month>
                  <name>Nov</name>
                  <monthdata>123</monthdata>
               </month> 
               <month>
                  <name>Dec</name>
                  <monthdata>89</monthdata>
               </month>            
            </months>
         </mx:Model> 

       

      <mx:Script>
            <![CDATA[

       


              import mx.events.ListEvent;
               import mx.collections.ArrayCollection;
              
               [Bindable] private var months:ArrayCollection = new ArrayCollection();

       

               private function init():void {
                  months = new ArrayCollection(custdata.month);
               }
              
               public function editCell(event:ListEvent):void {
                  myDG.editedItemPosition = {columnIndex:1, rowIndex:event.rowIndex};
               }

       

            ]]>
         </mx:Script>

       


      <mx:TitleWindow id="DataWindow" width="600" height="400" layout="absolute" title="Data" verticalCenter="-2" horizontalCenter="4" showCloseButton="true"  click="currentState='GraphState'" >
              <mx:DataGrid id="myDG" dataProvider="{months}" rowCount="5" width="300" height="290" editable="true" itemClick="editCell(event)"  x="138" y="44">
                 <mx:columns>
                    <mx:DataGridColumn headerText="Month" width="100" dataField="name" editable="false" editorDataField="text" />
                    <mx:DataGridColumn headerText="Data" dataField="monthdata" width="100" editable="true" />
                 </mx:columns>
              </mx:DataGrid>
      </mx:TitleWindow>
      <mx:TitleWindow id="GraphWindow" width="600" height="400" layout="absolute" title="Data" verticalCenter="-2" horizontalCenter="4" showCloseButton="true" click="currentState='DataState'" >

       

                  <mx:ColumnChart id="column" height="350.45" color="0x323232"
                         showDataTips="true" dataProvider="{custdata}" x="4" width="569.6" y="4" >
                            
                         <mx:horizontalAxis>
                             <mx:CategoryAxis categoryField="Country" />
                         </mx:horizontalAxis>
                            
                         <mx:series>
                             <mx:ColumnSeries xField="Country" yField="Gold" displayName="Gold" showDataEffect="slideIn"/>
                            
                         </mx:series>
                     </mx:ColumnChart>
      </mx:TitleWindow>
      </mx:Application>

       

      Although I am asking thje closebutton to change state, clicking inside a wondow makes a state change (And I cant change the data if I would like to-because it changes stqte if I try to). Any ideas on how to fix this? Thank you