Scaling Your Images in Flash Player? Smooth Those Things!!!

I actually forgot to apply the “smoothing” property to a flash.display.Bitmap display object being scaled inside Flash Player. Just look at the difference such an oversight made!

Smoothing

Since I was using a flash.display.Loader display object to load the image up, and Loader has no smoothing property, I totally spaced on this and it’s been out there for months rendering images in a pretty crappy way. I just needed to assign the image data to a Bitmap object and use that for display instead.

1
2
3
4
5
6
private function imageLoaded(e:Event):void {
    var imageBitmap:Bitmap = imageLoader.content as Bitmap;
    imageBitmap.smoothing = true;
    imageDrag.addChild(imageBitmap);
    //scale away!
}

Easy.

Learn from my blunder- always make sure to enable smoothing!

This entry was posted in Flash and tagged , , , . Bookmark the permalink.

3 Responses to Scaling Your Images in Flash Player? Smooth Those Things!!!

  1. Ragona says:

    Good post, this seems to be an easy (but important) point to overlook. It’s worth noting that you can actually smooth loaded images in a single line:

    Bitmap(myLoader.content).smoothing = true;

  2. Neat. I love little shortcuts like that.

  3. John says:

    Thanks!! I was doing a scroller for a client which had Loaders embedded in an mc and couldn’t work out why turning the mc’s smoothing on didn’t smooth the images. This worked perfectly :)

Leave a Reply

Your email address will not be published. Required fields are marked *

*

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong> <pre lang="" line="" escaped="">