var subimage = new Bitmap();
subimage.bitmapData = new BitmapData(25, 25, true, 0);
addChild(subimage);
From everything I've read, this should be transparent. I'm seeing a big black square. What could cause that?
use this
new BitmapData(25, 25, true, 0x00000000);
instead of
new BitmapData(25, 25, true, 0);
0xFF000000 is black(0x000000) with alpha equal to 1
0x00000000 is black(0x000000) with alpha equal to 0
Here is a nice explanation how colors & alpha work: http://myflex.wordpress.com/2007/09/07/about-hex-color-codes-in-flex-as3/
//EDIT:
Dennis Krøger and strille are right, 0x00000000 == 0. Looks like the problem is somewhere else, not in the code you pasted in.
ActionScript uses a 32-bit hexadecimal numbers to represent color values with transparency. ARGB colors as 32 bit variables are specified by 4 groups of 8 bits each / or 2 hex each:
In binary: AAAAAAAA RRRRRRRR GGGGGGGG BBBBBBBB
In hex: AA RR GG BB
A represents the alpha value (transparency), R is rd, G is green, B is blue. Each group defines intensity of each of the colors channels, A is alpha, R is red, G is green, B is blue. Full intensity on the alpha channel means no alpha (FF) and no intensity (00) means full alpha. So a transparent pixel color value is 0x00rrggbb.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With