Make the loaded image smooth in ActionScript 3.0

[ 2009-05-25 18:33:43 | Author: liuhuan ]
Font Size: Large | Medium | Small
When we load image into flash, it is not smooth by default. When you rotate or transform the image you could probably get a pixelated effect. To make it smooth we can use the smoothing property newly added to Image class in as 3.0.
var _loader:Loader = new Loader();
_loader.load(new URLRequest("a.jpg"));
_loader.contentLoaderInfo.addEventListener(Event.COMPLETE,completeHandler);
function completeHandler(e:Event){
  e.target.content.smoothing = true
}

Here is the code i used in as 2.0, with the same effect:
function grabBitmap(mc) {
  var _mc = new flash.display.BitmapData(mc._width, mc._height, true);
  _mc.draw(mc);
  return (_mc);
}
target.replaceWithBitmap = function(mc) {
  var _mc1 = grabBitmap(mc);
  mc.attachBitmap(_mc1,1,"auto",true);
};
target.replaceWithBitmap(target);
Comments Feed Comments Feed: http://www.liuhuan.com/blog/feed.asp?q=comment&id=976

There is no comment on this article.

You can't post comment on this article.