以前不知道怎么样才能平滑,今天看了一个小技巧才知道,原来将image.content转为位图,设置位图对象的平滑属性为真就可以了,真简单啊!
下面这个例子做了对比测试,缩放一下就看出来了:
>> XML:
-
<?xml version="1.0" encoding="utf-8"?>
-
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" layout="horizontal">
-
<mx:Script>
-
<![CDATA[
-
private function smoothingImage():void{
-
Bitmap(smothingImg.content).smoothing = true;
-
}
-
]]>
-
</mx:Script>
-
<mx:VBox width="40%" height="100%" borderStyle="solid">
-
<mx:FormItem label="Not smoothing Image">
-
<mx:HSlider id="sldra" value="1" minimum="0" maximum="2" labels="[0,2]"/>
-
</mx:FormItem>
-
<mx:Image id="normalImg" source="assets/yangliu.jpg" scaleX="{sldra.value}" scaleY="{sldra.value}"/>
-
</mx:VBox>
-
<mx:VBox width="40%" height="100%" borderStyle="solid">
-
<mx:FormItem label="Smoothing Image">
-
<mx:HSlider id="sldrb" value="1" minimum="0" maximum="2" labels="[0,2]"/>
-
</mx:FormItem>
-
<mx:Image id="smothingImg" source="assets/yangliu.jpg" scaleX="{sldrb.value}" scaleY="{sldrb.value}"
-
complete="smoothingImage();"/>
-
</mx:VBox>
-
</mx:Application>