Skip to main content
Participant
July 19, 2009
Question

How to get the pixel color of a Graphics object?

  • July 19, 2009
  • 1 reply
  • 1187 views

for example,graphics is an object from a movieclip ojbect.I want to get the pixel color at the x,y location in the movieclip.How to do?

This topic has been closed for replies.

1 reply

kglad
Community Expert
Community Expert
July 20, 2009

use the draw() method of the bitmapdata class to create a bitmapdata instance and then use the getPixel() method of the bitmapdata class.

TopasnAuthor
Participant
July 20, 2009

I use bitmapdata to get the pixel color,but I got a trouble.

var bmp:BitmapData = new BitmapData(this.width,this.height,false);

bmp.draw(this);

trace(bmp.getPixel(event.localX,event.localY));

when the bmp call draw() function ,the ie report an a problem occured by the FIDbg10b.ocx and ended the program.

what wrong with this code?

kglad
Community Expert
Community Expert
July 20, 2009

what's "this" in your code?