1 Reply Latest reply on Mar 1, 2012 7:39 AM by MichaelRix

    Filter xml data Class and use pushView to populate List (Flex Mobile project)

    MichaelRix

      I am such noob so I apologize for my ignorance. Trying to learn and work at the same time but i'm stumped been searching and my understanding is not up to snuff just yet.

      I looked at the Mobile Shopping Cart that Adobe has little over my head to grasp and impliment but my project is similar without the cart option basically.

       

      I'm currently using a single view with 3 states

       

      <s:states>

      <s:State name="default"/>

      <s:State name="productView"/>

      <s:State name="detailsView"/>

      </s:states>

       

      Default state has a list that uses a xml file with categoryID number's that correspond with the main products xml file.

      Which when the item is selected it filters and updates the List on the productView and so on to the detailsView.

      Like this:

      Category -> Products-> Details

       

      I'm using a filterCollection from an .as Class file to complete this here is a small snipet.

       

      private function productService_resultHandler(event:ResultEvent):void

      {

      var productsArray:Array = new Array();

      var resultData:XMLList = event.result..product;

      for each (var p:XML in resultData) {

      var product:Product = Product.buildProductFromAttributes( p );

           productsArray.push( product );

      }

      products = new ArrayCollection( productsArray );

           products.filterFunction = filterForCategory;

           products.refresh();

      }

      private function filterForCategory(item:Product):Boolean{

      return item.catID == selectedCategory;

      }

      public function filterCollection(id:Number):void{

      selectedCategory = id;

           products.refresh();

      }

       

      Project works great but incredibly slow on Mobile device iOS. In-between the states I have transition animations and it bogs right down.

      So I was trying to experiment by using pushView and basically do the same but utilize Flex's viewNavigator to see if it speeds things up but I can't get the filter function to push the filtered data to the newView component.

      Or I was thinking of trying to order the events such as seletedItem->transition->filtered Data it seems like it is all happing at once and the app just sits for 3 seconds before the state is updated.

       

      Any help appreciated or more info needed let me know. THX