11 Replies Latest reply on Nov 28, 2009 1:36 PM by sgammon10

    Possible bug? Issue switching between states and calling AMF methods


      Hello gumbo community,


      I have a pretty simple use case... I have a form with an input control and a search button. When the button is pushed, it runs the doSearch(); method (defined at the beginning of the MXML method in a script tag) and switches the state to 'Resultset', which is a results filter page.


      The doSearch method fires off the RemoteObject call, which then triggers the searchResultEvent method once a response is received from the AMF endpoint.


      Here is the relevant script/MXML:


                public function doSearch():void
                          Alert.show('Please enter at least one search term.');
                          return void;
                          searchService.SearchByDisplayText(searchText.text); // Triggers the searchResultEvent method
                public function searchResultEvent( event:ResultEvent ):void
                     var ResultData:Object = event.result;
                     if (ResultData.status == 'error')
                          Alert.show('An error was encountered: '+ResultData.text);
                     else if (ResultData.status == 'success')
                          searchFilterLabel.text = '"'+ResultData.query+'"';
                          entityFilterDataGrid.dataProvider = ResultData.result;
      <s:Button label="Search" includeIn="Base" id="doSearchButton" click="doSearch();currentState='Resultset'"/>


      When I try to run this code, it gives me an error relating to switching the state:


      TypeError: Error #1009: Cannot access a property or method of a null object reference.
           at mx.states::AddItems/addItemsToArray()[E:\dev\gumbo_beta2\frameworks\projects\framework\src\mx\states\AddItems.as:697]
           at mx.states::AddItems/apply()[E:\dev\gumbo_beta2\frameworks\projects\framework\src\mx\states\AddItems.as:535]
           at mx.core::UIComponent/applyState()[E:\dev\gumbo_beta2\frameworks\projects\framework\src\mx\core\UIComponent.as:9558]
           at mx.core::UIComponent/commitCurrentState()[E:\dev\gumbo_beta2\frameworks\projects\framework\src\mx\core\UIComponent.as:9327]
           at mx.core::UIComponent/setCurrentState()[E:\dev\gumbo_beta2\frameworks\projects\framework\src\mx\core\UIComponent.as:9220]
           at mx.core::UIComponent/set currentState()[E:\dev\gumbo_beta2\frameworks\projects\framework\src\mx\core\UIComponent.as:5740]
           at main/__doSearchButton_click()[/visualier/src/main.mxml:188]


      If I remove the currentState setting and just run the doSearch, I get a similar error about setting the text for the searchFilterLabel control. Those controls (the label and the datagrid) are in a seperate state... that shouldn't make a difference, right?


      Am I doing something wrong in this code?


      Thanks in advance.