# Hit test not working?!

**URL:** <https://forum.kirupa.com/t/hit-test-not-working/330932>\
**Category:** flash\
**Created:** [April 11, 2013, 4:23am UTC](https://forum.kirupa.com/t/hit-test-not-working/330932 "2013-04-11T04:23:43Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![na\_il](https://avatars.discourse-cdn.com/v4/letter/n/bc79bd/32.png) [@na\_il](https://forum.kirupa.com/u/na_il)\
**Post date:** [April 11, 2013, 4:23am UTC](https://forum.kirupa.com/t/hit-test-not-working/330932/1 "2013-04-11T04:23:43Z")

</div>

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?

```auto

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();
    
}

```
