# Nested call to funtion passing arguments

**URL:** <https://forum.kirupa.com/t/nested-call-to-funtion-passing-arguments/255740>\
**Category:** Uncategorized\
**Created:** [March 26, 2008, 2:40pm UTC](https://forum.kirupa.com/t/nested-call-to-funtion-passing-arguments/255740 "2008-03-26T14:40:48Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![xenos](https://avatars.discourse-cdn.com/v4/letter/x/ea5d25/32.png) [@xenos](https://forum.kirupa.com/u/xenos)\
**Post date:** [March 26, 2008, 2:40pm UTC](https://forum.kirupa.com/t/nested-call-to-funtion-passing-arguments/255740/1 "2008-03-26T14:40:48Z")

</div>

I have a movie clip called “aaa\_test\_clip.” One the first frame of aaa\_test\_clip, I created a button called “thebutton.” On the second frame of aaa\_test\_clip I have a blue graphic.

on the first frame of the root of my movie I wrote this function:

```auto

stop();
function doit(testvar:String):void {
    this["aaa_"+testvar+"_clip"].gotoAndStop(2);
}

```

If I write on the next line

```auto
doit("test");

```

the function works and it takes you to the second frame of aaa\_test\_clip with the blue graphic.

My problem is that I would like to have the button call this function and the button function defined in the nested movie clip like this:

```auto

stop();
thebutton.addEventListener(
  MouseEvent.MOUSE_UP,
  function(evt:MouseEvent):void {
    MovieClip(this.root).doit("test");
  }
);

```

but when I click thebutton I get an error message:

TypeError: Error #1009: Cannot access a property or method of a null object reference.  
at MethodInfo-6()

What am I doing wrong here? I attached my fla.
