February 5th, 2007 by Kyle
Posted in: Flex, Flash Player, actionscript, mxml
I’ve been asked this by at least 4 customers and provided them with simple samples that set the stage.quality = StageQuality.BEST. This provides smoother image scaling, but at potentially some performance cost. You also have to use the loaded image’s content property, casting it to a bitmap in order to scale it. I don’t recall exactly where I found the info on this, but I Googled and didn’t find a good reference for doing this, so I thought I’d post my own solution.
Check out the code snippet:
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml"
applicationComplete="stage.quality = StageQuality.BEST">
<mx:Script>
<![CDATA[
private function handleImageComplete(event: Event): void {
var bitmap: Bitmap = ((event.target as Image).content as Bitmap);
if (bitmap != null) {
bitmap.smoothing = true;
}
}
]]>
</mx:Script>
<mx:HSlider id="zoomSlider"
height="150"
buttonMode="true" useHandCursor="true"
minimum="1" maximum="10"
snapInterval="1" tickInterval="1" value="1"/>
<mx:Image height="600" width="800"
scaleX="{zoomSlider.value}" scaleY="{zoomSlider.value}"
source="me.jpg" complete="handleImageComplete(event)" />
</mx:Application>





Recent Comments