2 Replies Latest reply on Dec 2, 2012 7:39 PM by heartgoon

    problem about Image in the itemrenderer

    heartgoon Level 1

      i have an itemrenderer like this:

      <s:BorderContainer x="0" y="0" width="100%" height="100%" borderWeight="-1" borderColor="0xb3b3b3" >

          <s:HGroup horizontalAlign="left" verticalAlign="middle" width="{this.width}" paddingTop="3" paddingBottom="3" paddingLeft="5">

              <s:Image id="chImage" width="132" height="99" source="@Embed('libs/default_bg.png')" smooth="true"/>

              <s:Label id="lb" verticalAlign="middle" horizontalCenter="0" textAlign="left"/> 



      it displays an Image and a line of text.The image comes from the internet and its url would be given in the dataProvider of my List.

      My List is like this:

      <s:List id="lst" width="100%" dataProvider="{dataArr}" itemRenderer="about.MyRenderer"

                      horizontalScrollPolicy="off" verticalScrollPolicy="on"/>

      in the itemrender i defined the dataChange even as this:

      public function onDatdaChange():void{


              lb.text = data.cname;

              chImage.source = data.imageUrl;



      i aimed to display remote Images when loaded,otherwise display a default one.

      However,i was unable to see the default image and before the remote images had been loaded there was a period and during which i counld only see a black.

      Then how could i reach my goal:display remote Images when loaded,and before display a default one.i want to show the default image until the remote one appear.

      plz help...

        • 1. Re: problem about Image in the itemrenderer
          JEEVAK CC

          Please use Loader for load image .

          check if loader complete , then display remote image otherwise default one.


          imgLoader = new Loader();

                                                  var context:LoaderContext = new LoaderContext();

                                                  context.checkPolicyFile = true;

                                                  context.applicationDomain = ApplicationDomain.currentDomain;


                                                  imgLoader.contentLoaderInfo.addEventListener(Event.COMPLETE,onComplet e);

                                                  imgLoader.contentLoaderInfo.addEventListener(ProgressEvent.PROGRESS,i mg_progressHandler)

                                                  imgLoader.load(new URLRequest(encodeURI(imagePath)),context);

          1 person found this helpful
          • 2. Re: problem about Image in the itemrenderer
            heartgoon Level 1

            thank u for your help