PDA

View Full Version : Perfect hitarea on mousemove?



log
October 22nd, 2008, 07:16 PM
http://img111.imageshack.us/img111/299/unnnnab6.jpg

suraj
October 23rd, 2008, 05:58 AM
Hi please try this hope this will help u. U have to use bitmapData classs for this.

import flash.display.BitmapData;
import flash.geom.Point;

var myBitmapData:BitmapData = new BitmapData(_root.mcRect._width, _root.mcRect._height, true, 0x000000ff);
myBitmapData.draw(_root.mcRect);
var mcClone:MovieClip = this.createEmptyMovieClip("mcClone", this.getNextHighestDepth());
mcClone.attachBitmap(myBitmapData, this.getNextHighestDepth());
var destPoint:Point = new Point(myBitmapData.rectangle.x, myBitmapData.rectangle.y);
var currPoint:Point = new Point();
var mouseListener:Object = new Object();

mouseListener.onMouseMove = function()
{
currPoint.x = _root._xmouse;
currPoint.y = _root._ymouse;
if(myBitmapData.hitTest(destPoint, 255, currPoint))
{
trace(">> Collision at x:" + currPoint.x + " and y:" + currPoint.y);
}
}
Mouse.addListener(mouseListener);


Thanks.

log
October 23rd, 2008, 06:17 AM
thank you suraj . I ve tried but doesn't trace the output.
i attach you the example. Please, could you see if i make an error?

suraj
October 23rd, 2008, 09:48 AM
Hi,
U hav set black color for mcRect. Thats why its not working properly. Plz change it by other color. b/c bitmapData is treating that color for transparency.

Plz change that black color n select anyone color for that mcRect. Ur code will work fine.

Bye TC

log
October 23rd, 2008, 03:06 PM
Hi,
U hav set black color for mcRect. Thats why its not working properly. Plz change it by other color. b/c bitmapData is treating that color for transparency.

Plz change that black color n select anyone color for that mcRect. Ur code will work fine.

Bye TC

thank you. Now working fine. But if I use this script for get perfect hitTest on Item-Subitem of my Horizontal menu, duplicate in mcRect, from bottom to top, it doesn't work.

http://img339.imageshack.us/my.php?image=testhitmw0.swf&width=1024 (http://img339.imageshack.us/my.php?image=testhitmw0.swf)