martedì, novembre 20, 2007

Flash 7, 8, 9 and Bitmap Smoothing

I ran across an obscure (to me) graphics error in Flash and thought I’d share. I was loading dynamic images in a Flash 7 file. When I upgraded it to Flash 8 or 9, my images were suddenly pixelating!

Reason: I was reading the kaourantin.net blog, and he states: “When you dynamically load a bitmap in a Flash 8 file, smoothing is always turned off and rotating or scaling an image will yield ugly artifacts.”  (He includes a workaround, but it requires more effort in this case than simply reverting to Flash Player 7.)

Further in the blog he mentions that this issue is fixed in ActionScript 3. There is now a fix: imgname.smooth=true. However, Grant Skinner identified yet another possible bug with image smoothing!

“The Bitmap object in ActionScript 3 reverts its .smoothing property to false whenever you change it's .bitmapData property. Because we were setting up our Bitmap objects in advance, then assigning BitmapData objects to them when they were created, it simply appeared as though smoothing just didn't work in our project.”

Meanwhile, if you’re not dynamically loading images (i.e. they are in your library), but you need to scale or rotate them, there is an easy solution: right mouse click and select properties. From there select “Allow Smoothing.”

Phew.