Skip navigation
Currently Being Moderated

problem about Image in the itemrenderer

Nov 25, 2012 6:53 PM

Tags: #flex_itemrenderer

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"/> 

    </s:HGroup>

</s:BorderContainer>

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{

    if(data){

        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...

 
Replies
  • Currently Being Moderated
    Nov 30, 2012 3:15 AM   in reply to heartgoon

    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(Even t.COMPLETE,onComplete);

                                            imgLoader.contentLoaderInfo.addEventListener(Prog ressEvent.PROGRESS,img_progressHandler)

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

     
    |
    Mark as:

More Like This

  • Retrieving data ...

Bookmarked By (0)

Answers + Points = Status

  • 10 points awarded for Correct Answers
  • 5 points awarded for Helpful Answers
  • 10,000+ points
  • 1,001-10,000 points
  • 501-1,000 points
  • 5-500 points