1 Reply Latest reply on Nov 25, 2007 4:52 AM by goingflex

    History Manager throws error

    goingflex
      I have
      <mx:Application xmlns:mx=" http://www.adobe.com/2006/mxml" layout="vertical" horizontalAlign="center" creationComplete="initApp();" implements="mx.managers.IHistoryManagerClient">
      <mx:states>
      <mx:State name="partners"/>
      </mx:states>
      I also have an accordion on currentState="" as follows:
      <mx:Accordion width="100%" height="90%" id="toppage_accordeon" historyManagementEnabled="true">
      I also have loadState ans SaveState as follows:
      public function initApp() :void
      {
      HistoryManager.register(this);
      HistoryManager.register(toppage_accordeon);
      addEventListener(StateChangeEvent.CURRENT_STATE_CHANGE,
      handleStateChange);
      initCollections();
      }

      /**
      * Implementation of saveState() method required by
      * the IHistoryManagerClient interface.
      */
      public function saveState() :Object
      {
      var historyState:Object = new Object();
      historyState.currentState = currentState;
      return historyState;
      }

      /**
      * Implementation of loadState() method required by the
      * IHistoryManagerClient interface.
      */
      public function loadState(historyState:Object) :void
      {


      // Temporarily ignore currentStateChange events.
      removeEventListener(StateChangeEvent.CURRENT_STATE_CHANGE,
      handleStateChange);

      if (historyState == null)
      { // TRICKY: Null value indicates that initial state is required.
      currentState = "";
      }
      else
      {
      currentState = historyState.currentState;
      }

      // Listen for currentStateChange events again.
      addEventListener(StateChangeEvent.CURRENT_STATE_CHANGE,
      handleStateChange);
      }

      public function handleStateChange(event:StateChangeEvent) :void
      {
      HistoryManager.save();
      }

      When I launch and change the accordion state I get an error as follows:
      TypeError: Error #1009: Il est impossible d'accéder à la propriété ou à la méthode d'une référence d'objet nul.
      at mx.managers::HistoryManagerImpl/save()[E:\dev\flex_3_beta2\sdk\frameworks\projects\framew ork\src\mx\managers\HistoryManagerImpl.as:555]
      at mx.managers::HistoryManager$/save()[E:\dev\flex_3_beta2\sdk\frameworks\projects\framework \src\mx\managers\HistoryManager.as:140]
      at mx.containers::Accordion/commitSelectedIndex()[E:\dev\flex_3_beta2\sdk\frameworks\project s\framework\src\mx\containers\Accordion.as:1775]
      at mx.containers::Accordion/commitProperties()[E:\dev\flex_3_beta2\sdk\frameworks\projects\f ramework\src\mx\containers\Accordion.as:1056]
      at mx.core::UIComponent/validateProperties()[E:\dev\flex_3_beta2\sdk\frameworks\projects\fra mework\src\mx\core\UIComponent.as:5552]
      at mx.managers::LayoutManager/validateProperties()[E:\dev\flex_3_beta2\sdk\frameworks\projec ts\framework\src\mx\managers\LayoutManager.as:517]
      at mx.managers::LayoutManager/doPhasedInstantiation()[E:\dev\flex_3_beta2\sdk\frameworks\pro jects\framework\src\mx\managers\LayoutManager.as:667]
      at Function/ http://adobe.com/AS3/2006/builtin::apply()
      at mx.core::UIComponent/callLaterDispatcher2()[E:\dev\flex_3_beta2\sdk\frameworks\projects\f ramework\src\mx\core\UIComponent.as:8338]
      at mx.core::UIComponent/callLaterDispatcher()[E:\dev\flex_3_beta2\sdk\frameworks\projects\fr amework\src\mx\core\UIComponent.as:8281]


      Is this my mistake or an issueon FB 3?

      Thx for help.