2 Replies Latest reply on Feb 23, 2010 10:33 AM by Luis Pedro Ferreira

    Gumbo + DataGroup + AMFPHP

    Luis Pedro Ferreira Level 1

      Hi. I'm trying to detect why i can't populate an ArrayCollection, as data provider of a DataGroup, with data coming from AMFPHP.


      All works fine with PHP and on the AMFPHP browser.

      Debugging the Flex application, all the data are received in the result event, but for some reason, i can't populate the ArrayCollection that is going to be the data provider of my DataGroup.


      Here's the code:


      public function all_colors_enabled(){
            $rs=$db->Execute("SELECT * FROM colors WHERE color_status=1 ORDER BY color_code ASC");
            while (!$rs->EOF){
                 $color_code[$i]['color_id'] = $rs->fields['color_id'];
                 $color_code[$i]['color_code'] = $rs->fields['color_code'];
           return $color_code;


                import mx.collections.ArrayCollection;
                import mx.rpc.events.ResultEvent;

                private var categoryArray:ArrayCollection = new ArrayCollection;

                private function init():void{

                private function all_categories_enabled_resultHandler(event:ResultEvent):void{
                     categoryGroup.dataProvider = event.result.category as ArrayCollection;
      (is this necessary?)

           <s:RemoteObject id="ro_categoryService" destination="amfphp" source="briconlineServices.categoryServices" showBusyCursor="true">
                <s:method name="all_categories_enabled" result="all_categories_enabled_resultHandler(event)"/>

      <s:DataGroup id="categoryGroup" y="150" height="100%" clipAndEnableScrolling="true">
                <s:VerticalLayout useVirtualLayout="true" gap="-1"/>
                          <LeftComponent:MenuCategory categoryName="{data.category_name}" categoryColor="{data.category_color_code}"/>

        • 1. Re: Gumbo + DataGroup + AMFPHP
          Luis Pedro Ferreira Level 1

          More information:


          If i set the DataGroup data provider like this:


          public function all_categories_enabled_resultHandler(e:ResultEvent):void{;
               categoryGroup.dataProvider = e.result;


          It returns this error:

          Multiple markers at this line: -dataProvider -1118: Implicit coercion of a value with static type Object to a possibly unrelated type mx.collections:IList.


          Probably because e.result is an Array and the DataGrid is expecting an iList as dataprovider, right?

          But how can i fix this??

          • 2. Re: Gumbo + DataGroup + AMFPHP
            Luis Pedro Ferreira Level 1




            private var categoryArray:ArrayCollection;


            public function all_categories_enabled_resultHandler(e:ResultEvent):void{;
                 categoryArray = new ArrayCollection(e.result as Array);


            And then set the DataGrou's dataprovider with categoryArray .