<?xml version="1.0" encoding="utf-8"?>
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml"
layout="horizontal"
backgroundColor="white"
creationComplete="init()" viewSourceURL="srcview/index.html">
<mx:Script>
<![CDATA[
private const rLum:Number = 0.2225;
private const gLum:Number = 0.7169;
private const bLum:Number = 0.0606;
private const bwMatrix:Array = [rLum, gLum, bLum, 0, 0,
rLum, gLum, bLum, 0, 0,
rLum, gLum, bLum, 0, 0,
0, 0, 0, 1, 0];
[Bindable]
[Embed('assets/image2.jpg')]
private var image2:Class;
private var image2Color:Bitmap;
private var image2BlackWhite:Bitmap;
private function init():void {
image2Color = new image2();
image2BlackWhite = new image2();
image2BlackWhite.filters = [cmf];
img1.source = image2BlackWhite;
img2.source = image2Color;
}
]]>
</mx:Script>
<mx:ColorMatrixFilter id="cmf" matrix="{bwMatrix}" />
<mx:VBox>
<mx:Label text="Black and white" />
<mx:Image id="img1" scaleX="0.5" scaleY="0.5" />
</mx:VBox>
<mx:VBox>
<mx:Label text="Original" />
<mx:Image id="img2" scaleX="0.5" scaleY="0.5" />
</mx:VBox>
</mx:Application>