<?xml version="1.0" encoding="utf-8"?>
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" fontSize="16" layout="absolute">
<mx:Script>
<![CDATA[
private function getBitmapFilter():BitmapFilter {
var color:Number = 0x656262;//阴影颜色。
var alpha:Number = 0.4; //调节阴影的透明度。值越小。越透明。
var blurX:Number = 35; //左右阴影的宽度。
var blurY:Number = 35; //上下边框的阴影宽度
var strength:Number = 2;
var inner:Boolean = false;
var knockout:Boolean = false;
var quality:Number = BitmapFilterQuality.HIGH;
return new GlowFilter(color,
alpha,
blurX,
blurY,
strength,
quality,
inner,
knockout);
}
]]>
</mx:Script>
<mx:Canvas width="414" height="318" filters="{[getBitmapFilter()]}"
borderStyle="solid" backgroundColor="#FFFFFF" horizontalCenter="-2" verticalCenter="34" borderThickness="5" borderColor="#010000" cornerRadius="20" themeColor="#ED8A9A" fontSize="6" y="77" x="137">
<mx:Image x="9" y="8" width="382" height="289" source="1.png" />
</mx:Canvas>
</mx:Application>
设置组件的filters属性,组件要设置边框和背景色样式才能看得出,下面是示例:
<mx:Canvas width="300" height="200" filters="{[getBitmapFilter()]}"
borderStyle="solid" backgroundColor="#FFFFFF"/>
可适当调节一些参数值来改变内阴影的效果。特别是inner及knockout两个属性,可以做出内阴影及外阴影,两个都是false为外阴影。