2 Replies Latest reply on Aug 9, 2011 12:05 AM by Vikash.kumar29

    Stumpped Out with Event sequence. Please help !!!

    Vikash.kumar29 Level 3
      Hello experts,
      I am using flex sdk 4.1 and currently completly stumpped out with event behaviour while using TabBar. Any help will be appreciable.
      Here is the complete scenario:
      When I normally click on any button having focus on dateField after clearing the selected date, then the event call sequence is :
      contentGroup.Canvas40.DateField44:change
      contentGroup.Canvas40.Button41:click
      where change of datefield is dispatched before button click due to focusout, which is correct.
      But actual problem comes when you click on the other tab button from the TabBar, then the event sequence is :
      contentGroup._DateFieldTest_TabBar1:changing
      contentGroup._DateFieldTest_TabBar1:change
      contentGroup.Canvas40.DateField44:change
      where change of datefield is dispatched after the tab change.
      In my actual applicatio, I am making my model dirty and on changing event I am preventing tab change, if my model is dirty.
      But due to the event sequence said above my model becomes dirty after tab change and leads to some unsaved data though my tab has been changed.
      Below is the sample code I have used for replicating said Issue:
      <?xml version="1.0" encoding="utf-8"?>
      <s:Application
      xmlns:s="
      library://ns.adobe.com/flex/spark"
      xmlns:mx="
      library://ns.adobe.com/flex/mx" minWidth="955" minHeight="600"
      xmlns:controls="
      com.jci.ebm.web.common.controls.*"
      xmlns:containers="
      com.jci.ebm.web.common.containers.*">
      <fx:Script>
      <![CDATA[
      private function log(event:Event):void
      {
      txtArea.text = txtArea.text +
      "\n" + event.currentTarget +':' + event.type;
      }
      ]]>
      </fx:Script>
      <s:layout>
      <s:VerticalLayout />
      </s:layout>
      <s:TabBar dataProvider="{vs}" changing="log(event)" change="log(event)"/>
      <mx:ViewStack id="vs" width="100%" height="50%">
      <s:NavigatorContent width="100%" height="100%" label="Tab 1">
      <mx:Canvas width="100%" height="100%">
      <s:Button label="Test" click="log(event)" x="10" y="20"/>
      <mx:DateField change="log(event)" editable="true" x="10" y="49"/>
      </mx:Canvas>
      </s:NavigatorContent>
      <s:NavigatorContent width="100%" height="100%" label="Tab 2">
      <mx:Canvas width="100%" height="100%"/>
      </s:NavigatorContent>
      </mx:ViewStack>
      <s:TextArea id="txtArea" width="100%" height="50%" />
      </s:Application>
      Any help will be appreciable. Please help !!!
      -Regards
      Vikash kumar