2 Replies Latest reply on Apr 23, 2007 7:01 AM by adjunkt

    Newbie Transition Bug

      Hi.. Im having a Transition Bug:

      The intended effect is that the page fades in from nothing.

      It works when triggred by the button, but when triggered by the combo the new page instantly appears, THEN vanishes, THEN fades in from nothing as intended:

      Sorry about the awful code. The application has no point. It is just buttons and features thrown together to learn about FLEX

      I have used bold to indicate the relevant code.


      <?xml version="1.0" encoding="utf-8"?>
      xmlns:mx=" http://www.adobe.com/2006/mxml"

      import mx.utils.ArrayUtil;
      public var currentPage:String="start";

      <mx:Model id="bookModel" source="assets/myData.xml"/>

      <mx:ArrayCollection id="pageArray"

      //import mx.collections.ArrayCollection;
      import mx.collections.ICollectionView;
      import mx.collections.IViewCursor;
      import mx.collections.SortField;
      import mx.collections.Sort;

      public var myCursor:IViewCursor;
      public var myArray:Array;
      public var myArrayCollection:ArrayCollection;

      public function gotoPage(pageId:String):void
      textPageBody.text = myCursor.current.body;
      //var value:String;
      //value = myCursor.current.id;
      myArrayCollection = new ArrayCollection(myArray);
      dataChoice.dataProvider = myArrayCollection;

      public function gotoCurrentPage():void
      var currentPage:String;

      public function changePageState():void

      public function initData():void
      var sort:Sort = new Sort();
      sort.fields = [new SortField("id", true)];
      pageArray.sort = sort;

      <mx:State name="helpState">
      <mx:SetProperty target="{panelMain}" name="width" value="350"/>
      <mx:SetProperty target="{panelMain}" name="title" value="Help Page"/>
      <mx:SetProperty target="{panelMain}" name="height" value="350"/>
      <mx:AddChild relativeTo="{panelMain}" position="lastChild">
      <mx:DataGrid x="10" y="132" height="88" width="310"
      <mx:DataGridColumn headerText="ID" dataField="id"/>
      <mx:DataGridColumn headerText="BODY" dataField="body"/>
      <mx:SetProperty target="{dataChoice}" name="height" value="72"/>
      <mx:SetProperty target="{dataChoice}" name="y" value="228"/>
      <mx:SetProperty target="{textPageBody}" name="height" value="43"/>
      <mx:SetProperty target="{txtAnswer}" name="y" value="97"/>
      <mx:SetProperty target="{txtAnswer}" name="height" value="27"/>
      <mx:Transition id="myTransition" fromState="*" toState="helpState">
      <mx:Dissolve target="{panelMain}" alphaFrom="0.0" alphaTo="1.0" duration="2000"/>


      <mx:Panel x="10" y="10" width="350" height="350" layout="absolute" title="my application" cornerRadius="12" id="panelMain">
      <mx:TextArea y="46" text="不用谢" fontSize="17" height="62" left="10" right="60" id="textPageBody"/>
      <mx:Button x="288" y="278" label="不" id="btnCharacter"/>
      <mx:TextArea x="10" y="111" width="310" id="txtAnswer"/>
      <mx:DataGrid x="10" y="158" width="250" id="dataChoice" change="gotoCurrentPage()">
      <mx:DataGridColumn headerText="CHOICES" dataField="text"/>
      <mx:DataGridColumn headerText="GOTO" dataField="goto"/>
      <mx:ComboBox x="10" y="14" change="changePageState()" id="comboPageState">
      <mx:Object label="Standard" data=""/>
      <mx:Object label="Help" data="helpState"/>
      <mx:Object label="Statistics" data="statisticsState"/>
      <mx:Button x="255" y="14" label="HELP!" click="currentState=&quot;helpState&quot;"/>

        • 1. Newbie Transition Bug

          Try changing the event change="changePageState()" from "change" to "valueCommit" or something like that: valueCommit="changePageState()".

          The problem is that Flex is updating the data before running the transition. You need to get it to run the transition before changing the data.

          If that doesn't fix it, could you post the XML data as per assets/myData.xml - sorry, I was having some trouble, because it kept giving errors without the XML.

          Hope that helps.
          • 2. Re: Newbie Transition Bug
            adjunkt Level 1
            SOLVED! thanks!

            (And thanks for going as far as trying to run it too)