BitmapData and transparency

August 4th, 2011 by Piotr Wierzgała Leave a reply »

If you used draw method from BitmapData class to copy some DisplayObject with transparency you may notice that all transparent pixels turned white. This is because you didn’t set properly parameters in BitmapData construcotr.

BitmapData(width:int, height:int, transparent:Boolean=true, fillColor:uint=0xffffffff)

By default BitmapData fills it’s background with white and to avoid this you have to set fillColor parameter to any transparent color.

var bitmapData:BitmapData = new BitmapData(someWidth, someHeight, true, 0x00ffffff);
bitmapData.draw(someDisplayObject);
Advertisement

Leave a Reply

Flexmaniaks on Facebook