4 Replies Latest reply on Jul 12, 2007 2:50 AM by JabbyPandaUA

    Amfphp --> Array --> horizontalList

    gongon2
      Hi! (sorry for my poor english..)
      I'd try yo populate an horizontalList width a list of images defined by an array loaded from mySql through an amfPHP simple service.
      Data (images path) are loaded correctly in the movie (in fact, you can see them in the dataGrid) but the horizontalList return a list of empty image fields.

      You can see it here :
      http://www.gongon2.com/flex/pippo/bin/OrizList.html

      This is the source code :

      <?xml version="1.0"?>

      <mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" layout="absolute" height="208" width="800" creationComplete="initApplicationPippo()">
      <mx:Script>
      <![CDATA[
      import mx.collections.*;
      import mx.controls.Image;
      import mx.rpc.events.ResultEvent;
      import mx.utils.ArrayUtil;


      [Bindable]
      public var pippo:Array;
      public var gatewayPippo : RemotingConnection;

      public function initApplicationPippo():void{
      gatewayPippo = new RemotingConnection( " http://www.gongon2.com/flashservices/gateway.php" );
      gatewayPippo.call( "sampleOL.getUserPhoto", new Responder(onResult, onFault),"1");
      }

      public function onResult( result : Array ) : void
      {
      pippo = result;
      myList.dataProvider = pippo;
      }


      public function onFault( fault : String ) : void
      {
      trace( fault );
      }

      ]]>
      </mx:Script>

      <mx:HorizontalList id="myList" columnWidth="100" rowHeight="100" columnCount="4" itemRenderer="mx.controls.Image" x="10" y="25" height="120" width="400"/>

      <mx:Image x="418" y="25" width="100" height="100" id="image" source="{myList.selectedItem.photoPath}"/>

      <mx:DataGrid dataProvider="{pippo}" x="578" y="25" id="grid" height="130" width="104">
      <mx:columns>
      <mx:DataGridColumn headerText="photoPath" dataField="photoPath"/>
      </mx:columns>
      </mx:DataGrid>

      <mx:Image x="690" y="25" width="100" height="100" source="{grid.selectedItem.photoPath}"/>
      </mx:Application>

        • 1. Re: Amfphp --&gt; Array --&gt; horizontalList
          gongon2 Level 1
          Anyone can help me??
          • 2. Re: Amfphp --&gt; Array --&gt; horizontalList
            JabbyPandaUA Level 3
            Instead of
            [Bindable]
            public var pippo:Array;

            use
            [Bindable]
            public var pippo: ArrayCollection
            • 3. Re: Amfphp --&gt; Array --&gt; horizontalList
              gongon2 Level 1
              quote:

              Originally posted by: JabbyPandaUA
              Instead of
              [Bindable]
              public var pippo:Array;

              use
              [Bindable]
              public var pippo: ArrayCollection






              I'declared a new ArrayCollection (pippoColl), but the result seems to be the same.... blank images fields...



              <?xml version="1.0"?>

              <mx:Application xmlns:mx=" http://www.adobe.com/2006/mxml" layout="absolute" height="208" width="800" creationComplete="initApplicationPippo()">
              <mx:Script>
              <![CDATA[
              import mx.collections.*;
              import mx.controls.Image;
              import mx.rpc.events.ResultEvent;
              import mx.utils.ArrayUtil;

              [Bindable]
              public var pippoColl:ArrayCollection;

              [Bindable]
              public var pippo:Array;

              //mi collego al servizio e interrogo lo script (l' "1" dopo 'onFault' è l'id del soggetto di cui voglio avere
              //le foto)

              public var gatewayPippo : RemotingConnection;
              public function initApplicationPippo():void{
              gatewayPippo = new RemotingConnection( " http://localhost/flashservices/gateway.php" );
              gatewayPippo.call( "sample3.getUserPhoto", new Responder(onResult, onFault),"1");

              }

              public function onResult( result : Array ) : void
              {
              pippo = result;
              initpippoColl(pippo);
              //myList.dataProvider = pippo;

              }


              public function onFault( fault : String ) : void
              {
              trace( fault );
              }

              public function initpippoColl(items:Array):void
              {
              pippoColl = new ArrayCollection(items);
              myList.dataProvider = pippoColl;
              }


              ]]>
              </mx:Script>
              <mx:HorizontalList id="myList" columnWidth="100" rowHeight="100" columnCount="4" x="10" y="25" height="120" width="400" itemRenderer = "mx.controls.Image"/>





              <mx:Image x="418" y="25" width="100" height="100" id="image" source="{myList.selectedItem.photoPath}"/>

              <mx:DataGrid dataProvider="{pippo}" x="578" y="25" id="grid" height="130" width="104">
              <mx:columns>
              <mx:DataGridColumn headerText="photoPath" dataField="photoPath"/>
              </mx:columns>
              </mx:DataGrid>

              <mx:Image x="690" y="25" width="100" height="100" source="{grid.selectedItem.photoPath}"/>
              </mx:Application>




              • 4. Re: Amfphp --&gt; Array --&gt; horizontalList
                JabbyPandaUA Level 3
                Ok, back your question

                In your declaration
                <mx:HorizontalList id="myList" columnWidth="100" rowHeight="100" columnCount="4" x="10" y="25" height="120" width="400" itemRenderer = "mx.controls.Image"/>

                I do not see where you set Image source property to a value.

                Please, rework your itemRenderer declaration to inline renderer where you set source property for the image

                http://www.adobe.com/devnet/flex/quickstart/using_item_renderers/