Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

AS3 Traces Bitmap as "[object Shape]" / Bug or feature, going loco

i need to use the GetPixel32 on an Object in a movieclip.

in order to get to that object i use:

var bitmap=clip.getChildAt(0);
//and then 
bitmap.bitmapData.getPixel32(x, y);

however, even though the childobject is a png i get an error and using

trace(clip.getChildAt(0));

traces "[object Shape]"

so does Flash convert certain bitmaps into shapes?

please see the this fla ( http://www.sendspace.com/file/uycmm5 ) to test it yourself.

Any ideas?

like image 202
zantafio Avatar asked Apr 19 '12 19:04

zantafio


1 Answers

Bitmaps placed in Flash's timeline are converted to shapes (with bitmapfill) on compilation, (UPDATE) unless the image in the library has a linkage name, in which case it works as expected and compiles to a Bitmap object.

You can however draw a new bitmap with that shape:

var shape:DisplayObject = clip.getChildAt(0);
var bmp:BitmapData = new BitmapData(shape.width, shape.height, true, 0);
bmp.draw(shape);
bmp.getPixel32(x, y);
like image 148
Cay Avatar answered Oct 03 '22 12:10

Cay