forceSmoothing

Rotating and scaling pictures in flash is easy. Just use _rotation, _xscale and _yscale. Except when you publish an swf for Flash Player 8 or newer. Every image you rotate or scale will become jagged. Very anoying. To remedy this you can either publish for Flash 7 or use a complicated loadBitmapSmoothed function that uses BitmapData.

When Flash Player 8.5 came out it introduced the forceSmoothing property. This property is also available in as2. Now all we need to do is set it to true when we load images. Don’t forget that this will have no effect in Flash players older than version 8.5!

It works quite well. In the example below you can clearly see the left picture is more jagged than the right one.

var outer_mc = this.createEmptyMovieClip("outer_mc", 0);
var inner_mc = outer_mc.createEmptyMovieClip("inner_mc", 0);

// don't rotate the inner_mc
// it will lose its properties when the image is loaded
outer_mc._rotation = 45;
outer_mc._xscale = 120;
outer_mc._yscale = 60;

var mcl:MovieClipLoader = new MovieClipLoader();

mcl.addListener({
  onLoadInit: function(target:MovieClip){
    // this prevents that awfully jagged look
    target.forceSmoothing = true;
  }
});

mcl.loadClip("image.jpg", inner_mc);

Comments are closed.