Flex で画像が表示されない
<?xml version="1.0"?>
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml">
<mx:Script><![CDATA[
public var photo:FileReference = new FileReference();
protected function crop_clickHandler():void
{
var f:FileFilter = new FileFilter("Image", "*.jpg;*.jpeg;*;*.gif;*.png;");
photo.addEventListener(Event.SELECT, fileSelected);
photo.browse([f]);
}
private function fileSelected(evt:Event):void
{
photo.addEventListener(Event.COMPLETE,loadCompleted);
photo.load();
}
private var loader : Loader = new Loader();
private function loadCompleted(evt:Event):void
{
loader.contentLoaderInfo.addEventListener(Event.COMPLETE, getBitmapData);
loader.loadBytes(photo.data);
}
private function getBitmapData(event:Event):void
{
var content:DisplayObject = loader.content;
var BMPData:BitmapData = new BitmapData(content.width,content.height);
// var imgObj:Object = new Object();
var bmd:BitmapData;
bmd = Bitmap(event.currentTarget.content).bitmapData;
var bmpMy:Bitmap = new Bitmap(bmd);
myImage1.source=bmpMy
// myImage1.addChild(DisplayObject(bmpMy));
}
]]></mx:Script>
ロード後にここに画像を表示しようとしましたが、試したとおりに機能していません
<mx:Button id="btnLoad" label="Browse Image" click="crop_clickHandler()" ></mx:Button>
<mx:Image id="myImage1" x="50" y="50" height="100%" width="100%" maintainAspectRatio="false" autoLoad="true" ></mx:Image>
</mx:Application>