Friday, January 25, 2008

“Best” Image Quality in Flash

A while back I was having a problem with animating a raster picture in Flash. I had a JPG image and wanted to animate its position and scale so it would move across the stage while growing bigger. This seemed simple enough, so I converted the JPG to a movie clip and set up a tween adjusting the keyframes and it previewed perfectly on the stage. I was less then impressed however when viewing the published SWF. For some reason my animated picture had very jagged edges and didn’t look smooth at all. Interestingly enough if I didn’t animate the clip or just scaled the image directly on the main timeline it looked fine when published. After much frustration and doing some investigating, I found the answer to my problem.

The Flash Player has an image quality setting with three selectable settings (Low, Medium or High) from the contextual menu when viewing a published flash file. You can see these settings by right clicking the screen in a running Flash SWF file and selecting <>. I always left this set at the default <> setting but what I didn’t realize is that there is a fourth setting called <> which solved my problem with poor quality images when animated. You can only set the quality to <> through action script but it’s a very simple line of code that can simply be pasted into the first frame of your Flash movie. The code is:

_quality = "BEST";

I found very little documentation on this but it’s so useful that I’ve gotten in the habit of putting it in most of my flash projects. Basically what it does is it applies an anti-aliasing filter to pictures in the Flash movie which smoothes out the scaled images. About the only time when you might not want to use this is if your movie has a lot of complex animations working at the same time. In a case like this using the <> setting may slow down the animation or make it look choppy so it may be better to use a lower setting. Most of the time though, this will be a great and easy way to get better looking animations.

No comments: