Flex: How to create an Image control from a flash.display.Bitmap?
I need to create an Image control from a Bitmap because I have an ItemRedender to use 开发者_StackOverflow社区in a List control.
I'm trying to show a list of images (Bitmaps) in a List control and I couldn't by now.
you can use a bitmap as an image just by creating a new image and setting the source of the image to the bitmap. You can do it like this:
var _image:Image = new Image();
_image.source = yourBitmap;
Try this example hopefully this will helps
Please modify image paths
<?xml version="1.0" encoding="utf-8"?>
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" layout="absolute">
<mx:Script>
<![CDATA[
[Embed(source="assets/<image1>")]
[Bindable]
public var img1:Class;
[Embed(source="assets/<image2>")]
[Bindable]
public var img2:Class;
[Bindable]
private var arr:Array = new Array({image:img1},{image:img2});
]]>
</mx:Script>
<mx:List dataProvider="{arr}" width="100%" height="100%">
<mx:itemRenderer>
<mx:Component>
<mx:Image source="{data.image}"/>
</mx:Component>
</mx:itemRenderer>
</mx:List>
</mx:Application>
精彩评论