The code is probably like this:
Copy Code code as follows:
Displaobject for need screenshot object
var pngencoder:pngencoder = new Pngencoder ();
var bitmapdata:bitmpadata = new Bitmpadata (displaobject.widht,displaobject.height);
Bitmapdata.draw (Displaobject);
var Imagebytearray:bytearray = Pngencoder.encode (BitMapData);
.....
Send the Imagebytearray to server side scripts .....
However, the results are not transparent and suspect that the Encode method does not contain an alpha channel. Change to the second method:
Copy Code code as follows:
var Bytes:bytearray = bitmapdata.getpixels (new Rectangle (0,0,bitmapdata.width,bitmapdata.height));
var Imagebytearray2:bytearray = Pngencoder.encodebytearray (bytes,bitmapdata.width,bitmapdata.height,true);
The result still has no transparency information!
So I read each of the manuals carefully and found the following passage:
Transparent:boolean (default = True)-refers to whether the anchored image supports different transparency for each pixel. The default value is true (transparent). To create a fully transparent bitmap, set the value of the transparent parameter to TRUE and set the value of the FillColor parameter to 0x00000000 (or set to 0). Setting the transparent property to false can slightly increase rendering performance.
In other words, transparent = True is not yet, FillColor must also be set to 0x000000!!
Copy Code code as follows:
var bitmapdata:bitmpadata = new Bitmpadata (displaobject.widht,displaobject.height,true,0x000000);
In fact, this setting is quite unreasonable, but later encounter problems or more to look at the manual!