I am loading a PNG with transparency into a UILoader. This part works
correctly, transparency and all.
Now I need to find out the rectangle that is transparent. I found the
getColorBoundsRect() function, and copied the UILoader.content into a
bitmapData, but when I run the getColorBoundsRect it comes back with a
Rectangle that has no width or height - IE, it finds no transparent pixels.
To test, I tried using getPixel32 on an area of the image I know is
transparent, and it comes back to tell me that the pixel alpha is 255?
Applicable code is attached.
function rightImageLoaded(evt:Event):void {
var clBD:BitmapData = new BitmapData(735,600,true);
clBD.draw((evt.target as UILoader).content);
var transparentRect:Rectangle =
clBD.getColorBoundsRect(0xFF000000,0x00000000,true);
trace(transparentRect);
}
rritchey - 29 Sep 2008 19:26 GMT
I am an idiot. I forgot to set a parameter in the BitmapData constructor,
which tells it to keep transparent pixels transparent. BitmapData defaults to
changing transparent pixels to white, which is why I was having problems.
var clBD:BitmapData = new BitmapData(735,600,true,0x00FFFFFF);