# Pass a non-initiated Sprite into a function

**URL:** <https://forum.kirupa.com/t/pass-a-non-initiated-sprite-into-a-function/329024>\
**Category:** flash\
**Created:** [July 14, 2012, 2:23am UTC](https://forum.kirupa.com/t/pass-a-non-initiated-sprite-into-a-function/329024 "2012-07-14T02:23:06Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![Tompa](https://avatars.discourse-cdn.com/v4/letter/t/6de8d8/32.png) [@Tompa](https://forum.kirupa.com/u/Tompa)\
**Post date:** [July 14, 2012, 2:23am UTC](https://forum.kirupa.com/t/pass-a-non-initiated-sprite-into-a-function/329024/1 "2012-07-14T02:23:06Z")

</div>

Hello again!  
I’ve got stuck in my current project, here is the code related to my problem:

```auto
playerMallet = new PlayerMallet(main_class);
addChild(playerMallet);
            
[COLOR=#ee82ee]enemyMallet [/COLOR]= new EnemyMallet([COLOR=#ff8c00]puck[/COLOR]);
addChild(enemyMallet);    

var [COLOR=#ff8c00]puck[/COLOR]:Puck = new Puck(playerMallet, [COLOR=#ee82ee]enemyMallet[/COLOR], this);
addChild(puck);

```

As you can see, the enemyMallet is trying to pass the [COLOR=#ff8c00]\*\*puck \*\*[/COLOR]instance as a parameter, but this gives me this error obviously:

```auto
[COLOR=#ff0000]Error #1009: Cannot access a property or method of a null object reference.[/COLOR]

```

This is becuase puck isn’t yet initiated yet.

It doesn’t matter which of these 3 instances I initiate first, one of them will always fail because all 3 can’t be initiated at once _(or can they… ?)_

_~Tompa_
