# instanceName as variable problem

**URL:** <https://forum.kirupa.com/t/instancename-as-variable-problem/248408>\
**Category:** flash\
**Created:** [January 8, 2008, 12:11am UTC](https://forum.kirupa.com/t/instancename-as-variable-problem/248408 "2008-01-08T00:11:15Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![snolfi](https://avatars.discourse-cdn.com/v4/letter/s/9dc877/32.png) [@snolfi](https://forum.kirupa.com/u/snolfi)\
**Post date:** [January 8, 2008, 12:11am UTC](https://forum.kirupa.com/t/instancename-as-variable-problem/248408/1 "2008-01-08T00:11:15Z")

</div>

I’m pretty new to AS, so I hope I can explain this properly. I have about 25 buttons that all should open different pdf’s. The pdf file names correspond to the instance names, so I figured I could setup one function and eventListener using instanceName.

```auto

stop();

function btnFunction(event: MouseEvent) {
    var countypdf:URLRequest = new URLRequest("file_location");
    navigateToURL(countypdf);
}

getChildByName("instanceName").addEventListener(MouseEvent.CLICK, btnFunction);

```

My main question is that I keep getting this message: Error #1009: Cannot access a property or method of a null object reference. And I don’t know how to fix it.

I’m also hoping someone might be able to tell me the proper way to use getChildByName(“instanceName”) inside of the “file\_location” so that the URL would result in “instanceName”.pdf
