3 Replies Latest reply on Jun 6, 2010 3:01 AM by David_F57

    s:list bind pictures dynamical?

    RealBillyBlue Level 1

      Hey there,

      I build a new project and bind a DB via the Flex-Builder PHP-Assistant and added a s:list to my project.

       

      This works very good. One of my columns includes a filename for a pictures, which I want to add to the s:list via ItemRenderer.

       

      My question is now: How can I read out this one special column to give the filename to the ItemRenderer, so my picture shows in the s:list?

       

      <?xml version="1.0" encoding="utf-8"?>
      <s:Application xmlns:fx="http://ns.adobe.com/mxml/2009" 
                        xmlns:s="library://ns.adobe.com/flex/spark" 
                        xmlns:mx="library://ns.adobe.com/flex/mx" minWidth="955" minHeight="600" xmlns:adressesservice1="services.adressesservice1.*">
           <fx:Script>
                <![CDATA[
                     import mx.controls.Alert;
                     import mx.events.FlexEvent;
                     
                     protected function list_creationCompleteHandler(event:FlexEvent):void
                     {
                          getAllAdressesResult.token = adressesService1.getAllAdresses();
                     }
                     
                ]]>
      
           
           </fx:Script>
           <fx:Declarations>
                <s:CallResponder id="getAllAdressesResult"/>
                <adressenservice1:AdressesService1 id="adressesService1" fault="Alert.show(event.fault.faultString + '\n' + event.fault.faultDetail)" showBusyCursor="true"/>
           </fx:Declarations>
      
           
           <s:List x="189" y="194" width="692" height="234" id="list" creationComplete="list_creationCompleteHandler(event)" labelField="Name">
                <s:layout>
                     <s:TileLayout/>
                </s:layout>
                <s:AsyncListView list="{getAllAdressesResult.lastResult}"/>
           </s:List>
      </s:Application>
      

        • 1. Re: s:list bind pictures dynamical?
          SpaghettiCoder Level 3

          itemRenderers have a data property, just bind your image which is part of your itemrenderer.

           

          <mx:Image

           

          source="{data.Picture}.jpg"

          1 person found this helpful
          • 2. Re: s:list bind pictures dynamical?
            RealBillyBlue Level 1

            No, as you can see the assistant-generated code uses this line to transfer the full dataset to the s:list:

             

            <s:AsyncListView list="{getAllAdressesResult.lastResult}"/>

             

            So there's no space between this code to add the ImageRenderer for the picture to every entry yet.

             

            I need an example s:list with an implemented ImageRenderer.

             

             

            In a DataGrid I could just set the ImageRenderer between the lines:

             

                 <mx:DataGrid id="dataGrid" dataProvider="{getAllAdressesResult.lastResult}">
                      <mx:columns>
                           <mx:DataGridColumn headerText="Name" dataField="Name"/>
                           <mx:DataGridColumn headerText="Firstname" dataField="Firstname"/>
                                    >> HERE <<
                      </mx:columns>
                 </mx:DataGrid>
            

             

            ..because it reads the data from the provider by 'dataField' and not by a single line.

             

            I'm new to Flex and dynamic-databinding. I'm not sure how to handle the generated CallResponder

             

            Sorry for my bad english, I hope you could understand what my problem is.

            • 3. Re: s:list bind pictures dynamical?
              David_F57 Level 5

              hi,

               

              Have a look at this

               

              http://flashhub.net/filter/  source included

               

              it retreives data from a database I add the result to an arraycollection then display in a list. Everything you need to understand the itemrendering should be in this example.

               

               

              David

              1 person found this helpful