开发者

Flex ItemRenderer Images not appearing at runtime

in datagrid I have an ItemRenderer (which extends UIComponent) which 开发者_StackOverflowloads images based on a data value, eg:

 _img.source = "assets/images/flags/" + value[dglistData.dataField] + ".gif"; 

When I run my application the images (flags) are appearing in the ItemRenderer. When I build and deploy the application into BlazeDS as an SWF file - the images do not appear. Instead there is the standard "missing icon" link that appears in Internet explorer.

As far as I can tell, my ANT build script includes the above directory "assets/images/flags/" and all the images into the SWF file.

Is this a relative path issue? Not sure, any help would be appreaciated.

Thanks Mike


When you are assigning a path as source Flash Player is trying to load the images via HTTP requests. Therefore, embedding your images in the SWF has no effect.

There are two possible solutions. Either deploy the folder containing your images to the server and use the corresponding path as your source or embed all your images into the SWF.

A simple example for the second solution. The code assumes that value[dglistData.dataField] corresponds to one of the variables with the [Embed] metadata.

[Embed(source='assets/images/flags/Image1.png')]
private var image1:Class;

[Embed(source='assets/images/flags/Image2.png')]
private var image2:Class;

[Embed(source='assets/images/flags/Image3.png')]
private var image3:Class;

// access the image like this...
_img.source = this[value[dglistData.dataField]]; 
0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜