Flex:如何从flash.display.Bitmap创建一个Image控件?

时间:2011-04-12 12:00:52

标签: flex image list itemrenderer

我需要从Bitmap创建一个Image控件,因为我有一个ItemRedender可以在List控件中使用。

我正在尝试在List控件中显示图像列表(位图),而我现在还不能。

先谢谢。

2 个答案:

答案 0 :(得分:2)

只需创建新图像并将图像源设置为位图,即可将位图用作图像。你可以这样做:

var _image:Image = new Image();
_image.source = yourBitmap;

答案 1 :(得分:1)

尝试这个例子,希望这会有所帮助

请修改图片路径

<?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>
相关问题