# My Two different Instance objects does not collide

**URL:** <https://forum.kirupa.com/t/my-two-different-instance-objects-does-not-collide/281235>\
**Category:** flash\
**Created:** [February 6, 2009, 11:22am UTC](https://forum.kirupa.com/t/my-two-different-instance-objects-does-not-collide/281235 "2009-02-06T11:22:47Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![kilamantok](https://avatars.discourse-cdn.com/v4/letter/k/c68b51/32.png) [@kilamantok](https://forum.kirupa.com/u/kilamantok)\
**Post date:** [February 6, 2009, 11:22am UTC](https://forum.kirupa.com/t/my-two-different-instance-objects-does-not-collide/281235/1 "2009-02-06T11:22:47Z")

</div>

Thank you very much for giving some time to read my problem.

Im building a shooter game where a bullet is call from a class and the enemy is also called from a class.

I cant make them collide. In order for stuff to start exploding.

I keep getting this error

```auto
1120:Access of undefined property nBullet

```

```auto
//This one creates a meteor by calling class Meteor every 2 seconds

var meteorTimer:Timer=new Timer(2000);
meteorTimer.start();
meteorTimer.addEventListener(TimerEvent.TIMER, bulletMeteor, false , 0 , true);

function bulletMeteor(evt:TimerEvent):void {

    var nMeteor:Meteor= new Meteor();
    nMeteor.x=800;
    nMeteor.y=Math.random()*380+10;
    addChild(nMeteor);
    nMeteor.addEventListener(Event.ENTER_FRAME, rMeteor);
    function rMeteor(evt:Event):void {
        if (nMeteor.x<=-10) {
            removeChild(nMeteor);
            nMeteor.removeEventListener(Event.ENTER_FRAME, rMeteor);
        }
        if (nMeteor.hitTestObject(nBullet)) {
            trace("collision detected");
            removeChild(nMeteor);
            nMeteor.removeEventListener(Event.ENTER_FRAME, rMeteor);
        }
        if (PixelPerfectCollisionDetection.isColliding(nMeteor,nBullett,stage,true,255)) {

            trace("collision detected");
            removeChild(nMeteor);
            nMeteor.removeEventListener(Event.ENTER_FRAME, rMeteor);
        }
    }
}

// _____________________________________________________________________________________________________

// This one creates a bullet by calling class Bullet

stage.addEventListener(MouseEvent.CLICK, addBullet);
function addBullet(evt:MouseEvent):void {
    var xSpeed:Number =(hTarget/radius)*-10;
    var ySpeed:Number =(dTarget/radius)*10;
    var nBullet:Bullet = new Bullet();
    nBullet.x=centerX;
    nBullet.y=centerY;
    nBullett.rotation=angle;
    addChildAt(nBullet,0);
    addEventListener(Event.ENTER_FRAME, moveBullet);
    function moveBullet(evt:Event):void {
        nBullet.x+=xSpeed;
        nBullet.y+=ySpeed;
        if (nBullet.y<0||nBullet.y>400||nBullet.x<0||nBullet.x>801) {
            removeChild(nBullet);
            removeEventListener(Event.ENTER_FRAME, moveBullet);
        }
    }
}

```

any kind of help will be greatly appreciated!
