2
votes

I'm working on a project where we have artists importing movieclips and bitmaps to the library via. flash, and sometimes i'm accessing a movieclip with multiple bitmap children. I need to access and scale all kinds of bitmaps from all kinds of places in my code.

I know i can set the smoothing of a bitmap by accessing myBitmap.smoothing, but i would like to have a global value that could be set so that the smoothing was true by default, and not false.

I've been looking at the documentation for bitmaps, but it doesn't say anything about any global values that can be set with this.

So my main question: Do any of you know of a way to enable smoothing for all bitmaps i work with, so i won't have to set it for each bitmap i add?

2

2 Answers

1
votes

I am assuming that your main problem is that the bitmaps are mainly imported manually into the Flash IDE and placed inside movieclips, and that's why Ihsan's solution may not work since you don't have a reference to all those bitmaps.

If that's indeed the case then one easy solution would be to set a rule then whenever a bitmap is imported, the "Allow smoothing" option in the properties box is always checked. That would work irrespective of how many people are working on importing bitmap assets to your project.

4
votes

WARNING: This answer only applies to the bitmaps made via new Bitmap calls.

No, there is no global switch for doing that.

Easiest method is finding new Bitmap calls and setting smoothing to true on your sources.

You may subclass the Bitmap class and write a modified constructor like that

 package somewhere.at.your.dirs {

 import flash.display.Bitmap;

 public class MyBitmap extends Bitmap{

 public  function MyBitmap(
     bitmapData:BitmapData = null, 
     pixelSnapping:String = "auto", 
     smoothing:Boolean = true) { 

     super(bitmapData, pixelSnapping, smoothing);
 }
 }
 }

Save this code to somewhere/at/your/dirs/MyBitmap.as

Then find and replace "new Bitmap" with "new MyBitmap" in your files. And in that case, you should import somewhere.at.your.dirs.MyBitmap too. Generally speaking this should not bring allergic reactions. But in case functions does not accept your "MyBitmaps" they can be casted down to Bitmaps by (Bitmap)myBmp...

Another not - so - practical method is below:

 package somewhere.at.your.dirs{

 import flash.display.Bitmap;

 public function newSmoothBitmap(
     bitmapData:BitmapData = null, 
     pixelSnapping:String = "auto", 
     smoothing:Boolean = true): Bitmap { 

     return(new Bitmap(bitmapData, pixelSnapping, smoothing));
 }
 }

Save this code to somewhere/at/your/dirs/newSmoothBitmap.as

Then find and replace "new Bitmap" with "newSmoothBitmap" in your files. And in that case, you should import somewhere.at.your.dirs.newSmoothBitmap too.