[英]Flex: How to create an Image control from a flash.display.Bitmap?
我需要從位圖創建一個 Image 控件,因為我有一個 ItemRedender 要在 List 控件中使用。
我正在嘗試在 List 控件中顯示圖像列表(位圖),但現在我不能。
您只需創建一個新圖像並將圖像源設置為位圖即可將位圖用作圖像。 你可以這樣做:
var _image:Image = new Image();
_image.source = yourBitmap;
試試這個例子希望這會有所幫助
請修改圖片路徑
<?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>
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.