<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" viewSourceURL="src/EmbeddingImages/index.html" layout="horizontal" width="626" height="626">
<mx:Image id="imageID" source="1.PNG" x="55" complete="image_bitmap(event);" mouseDown="image_click(event)"/>
<mx:Script>
<![CDATA[
import mx.graphics.BitmapFill;
import mx.controls.Alert;
import flash.display.Bitmap;
private var bm:Bitmap;
private var bmd:BitmapData;
private function image_click(e:MouseEvent):void
{
var color:int = bmd.getPixel(e.localX, e.localY);
Alert.show(color.toString(16).toUpperCase());
}
private function image_bitmap(e:Event):void
{
bm = imageID.content as Bitmap;
bmd = new BitmapData(imageID.contentWidth, imageID.contentHeight);
bmd.draw(bm.bitmapData);
}
]]>
</mx:Script>
</mx:Application>
No comments:
Post a Comment