开发者

Spark ItemRenderer not showing contents

I have a spark list component and a corresponding custom itemrenderer:

list component:

<s:List id="albumImagesList" itemRenderer="the.namespace.for.XYZImageRenderer" useVirtualLayout="false" width="400" height="160">
    <s:layout>
        <s:TileLayout requestedColumnCount="5"
                requestedRowCount="2"
                rowHeight="80"
                columnWidth="80"
                horizontalGap="0"
                verticalGap="0" />
    </s开发者_开发技巧:layout>
</s:List>

item renderer:

<?xml version="1.0" encoding="utf-8"?>
<s:ItemRenderer xmlns:fx="http://ns.adobe.com/mxml/2009" 
                xmlns:s="library://ns.adobe.com/flex/spark" 
                xmlns:mx="library://ns.adobe.com/flex/mx"
                autoDrawBackground="true" width="100%" height="100%">
    <s:states>
        <s:State name="normal" />
    </s:states>

    <s:BitmapImage source="{data.image_path}" width="70" height="70" horizontalCenter="0" verticalCenter="0" />

</s:ItemRenderer>

It's all fine and dandy, the data gets populated correctly and I verified that the data.image_path property arrives safe and sound inside the itemrenderer.

My only problem is: the image is not displaying. I am not sure if it doesn't render at all or if it's just not visible somehow.

Does anyone see something at first glance? Am I doing something fundamentally wrong here? I worked with mx item renderers before and I never had so much trouble with those.


after a little bit of fumbling and checking i suppose this is the answer to my question. maybe someone can confirm this, but i think it is pretty much spot on:

the "bitmapimage" can only load data from trusted (crossdomain-policy'ed) domains. so with local files it is no problem, but i was loading remote images and with that the bitmapimage silently shuts down and does nothing. no get request, nothing.

the old "image" can load stuff no matter where it originated and so i am now switching to this as a solution.


BitMapImage.source expects one of three things. To quote from docs:

  • A Bitmap or BitmapData instance.
  • A class representing a subclass of DisplayObject. The BitmapFill instantiates the class and creates a bitmap rendering of it.
  • An instance of a DisplayObject. The BitmapFill copies it into a Bitmap for filling.

It sounds like you're giving it a URL location. If so, then use an Image, not BitMapImage.


phew, ok got it fixed using this guy's approach: http://polygeek.com/2452_flex_extending-spark-bitmapimage

maybe it's going to be of help for someone.

cheers!

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜