# Error 1009 Problems

**URL:** <https://forum.kirupa.com/t/error-1009-problems/304792>\
**Category:** flash\
**Created:** [February 14, 2010, 12:55am UTC](https://forum.kirupa.com/t/error-1009-problems/304792 "2010-02-14T00:55:43Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![Kainevg](https://avatars.discourse-cdn.com/v4/letter/k/278dde/32.png) [@Kainevg](https://forum.kirupa.com/u/Kainevg)\
**Post date:** [February 14, 2010, 12:55am UTC](https://forum.kirupa.com/t/error-1009-problems/304792/1 "2010-02-14T00:55:43Z")

</div>

Hey guys,

I am currently devoloping my game and at run-time I get the error 1009…  
This is just a test file but what im trying to do is there will be 2 buttons, a button to spawn some guys and a button to make them shoot… When you click the spawn button once it will spawn a guy, you click it again and it will spawn him again but in a different spot… that works fine, but what I need it to do is to make it so you can click on either guy, which selects him then you click shoot and he starts to shoot…

I spawn both, I click on the top one, then Click shoot… he shoots, I click on the bottom one and try to shoot and I get the error: Error #1009: Cannot access a property or method of a null object reference.

If I do it vice versa I can get them both to shoot, I still get the errors but they are shooting…

The code is:

```auto
import com.cfreps.utils.GlobalVar;
var RifleSquadNum:GlobalVar = new GlobalVar();
var RSquad1Select:GlobalVar = new GlobalVar();
var RSquad2Select:GlobalVar = new GlobalVar();
RifleButton.addEventListener(MouseEvent.MOUSE_DOWN, RifleHandler);
 
function RifleHandler (e:MouseEvent)
 {
  RifleSquadNum.incData(1)
  if(RifleSquadNum.getVar() == 1)
   {
    var RifleSquad1:RifleSquad = new RifleSquad();
    RifleSquad1.x = 450
    RifleSquad1.y = 100
    addChild(RifleSquad1);
 
    RifleSquad1.addEventListener(MouseEvent.MOUSE_DOWN, Rifle1Handler);
     function Rifle1Handler (e:MouseEvent)
      {
       if(RSquad1Select.getVar() == 0)
        {
         RSquad1Select.incData(1)
        }
       else if(RSquad1Select.getVar() == 1)
        {
         RSquad1Select.incData(0)
        }
      }
   }
  if(RifleSquadNum.getVar() == 2)
   {
    var RifleSquad2:RifleSquad = new RifleSquad();
    RifleSquad2.x = 450
    RifleSquad2.y = 150
    addChild(RifleSquad2);
 
    RifleSquad2.addEventListener(MouseEvent.MOUSE_DOWN, Rifle2Handler);
     function Rifle2Handler (e:MouseEvent)
      {
       if(RSquad2Select.getVar() == 0)
        {
         RSquad2Select.incData(1)
        }
       else if(RSquad2Select.getVar() == 1)
        {
         RSquad2Select.incData(0)
        }
      }
   }
 
 
 ShootButton.addEventListener(MouseEvent.MOUSE_DOWN, ShootHandler);
 function ShootHandler (e:MouseEvent)
 {
  if(RSquad1Select.getVar() == 1)
   {
    RifleSquad1.gotoAndStop(2)
 
   }
  else if(RSquad2Select.getVar() == 1)
   {
    RifleSquad2.gotoAndStop(2)
 
   }
 }
 
 
 
 
 }

```

The problem is at line 63 which is in the ShoootHandler function and is:

```auto
RifleSquad1.gotoAndStop(2)

```

Thanks heaps - Kaine
