Maybe im too frustrated right now and am looking over a simple mistake, but i don’t understand why this isn’t working? I want the alpha the be 50 percent if MC intersect and 100 percent if they don’t. Is it the dragging that is messing it up?
var rect1:Rectangle = obj1.getBounds(obj1.stage);
var bmp1:BitmapData = new BitmapData(rect1.width,rect1.height,true,0);
var mtx1:Matrix = obj1.transform.matrix;
mtx1.tx = obj1.x-rect1.x;
mtx1.ty = obj1.y-rect1.y;
bmp1.draw( obj1, mtx1 );
var rect2:Rectangle = obj2.getBounds(obj2.stage);
var bmp2:BitmapData = new BitmapData(rect1.width,rect1.height,true,0);
var mtx2:Matrix = obj2.transform.matrix;
mtx2.tx = obj2.x-rect1.x;
mtx2.ty = obj2.y-rect1.y;
bmp2.draw( obj2, mtx2 );
stage.addEventListener(Event.ENTER_FRAME, hitTest);
function hitTest(e:Event){
if ( bmp1.hitTest( new Point(), 0xFFFFFF, bmp2, new Point() )){
this.alpha = .5;
trace("cool");
}
else
{
this.alpha = 1;
stage.removeEventListener(Event.ENTER_FRAME, hitTest);
}
}
this.addEventListener(MouseEvent.MOUSE_DOWN, beginDrag);
this.addEventListener(MouseEvent.MOUSE_UP, endDrag);
function beginDrag(e:MouseEvent)
{
e.target.startDrag();
}
function endDrag(e:MouseEvent)
{
e.target.stopDrag();
}