Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

dectect a mouseover event on the black pixels within a bitmap

Status
Not open for further replies.

ugly

Programmer
Jul 5, 2002
70
GB
I dynamically place a bitmap graphic on my stage. I also place a textbox called feedback. The bitmap is black and white. On a mouse over action I would like the text box to tell me when the mouse is positioned over a black pixel(within the bitmap). The bitmap does show
the graphic but the mouseover action shows no matter where the cursor is, I would like it to tell me when its over just the bitmap and in particular any black pixels contained within the bitmap.
Thanks for any help



import flash.display.BitmapData;
var myBitmap:BitmapData = new BitmapData(clip1._width, clip1._height);
myBitmap.draw(clip1);
this.createEmptyMovieClip("copy1", 0);
copy1.attachBitmap(myBitmap, 0);

//the above shows the graphic on the screen

onMouseOver = function () {
feedback.text = "You are over the bitmap";
};

myListener = new Object();
copy1.addListener(myListener);
 
Code:
import flash.display.BitmapData;
var myBitmap:BitmapData = new BitmapData(clip1._width, clip1._height);
myBitmap.draw(clip1);
this.createEmptyMovieClip("copy1", 0);
copy1.attachBitmap(myBitmap, 0);
//the above shows the graphic on the screen
copy1.onMouseMove = function():Void  {
	feedback.text = myBitmap.getPixel(_xmouse, _ymouse);
};
If it says "0" it means black.

Kenneth Kawamoto
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top