# Function call problem

**URL:** <https://forum.kirupa.com/t/function-call-problem/5157>\
**Category:** Uncategorized\
**Created:** [September 3, 2002, 10:48am UTC](https://forum.kirupa.com/t/function-call-problem/5157 "2002-09-03T10:48:57Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![catalas](https://avatars.discourse-cdn.com/v4/letter/c/50afbb/32.png) [@catalas](https://forum.kirupa.com/u/catalas)\
**Post date:** [September 3, 2002, 10:48am UTC](https://forum.kirupa.com/t/function-call-problem/5157/1 "2002-09-03T10:48:57Z")

</div>

Hi,  
I get a problem when I call a function in a movie clip.  
I place a movie clip named “aMC” in the first frame of the root timeline. Inside the movie clip, there is a function call testFunc(). I add some action script in the first frame of the root timeline.  
That action script is:

```
_root.aMC.testFunc();

I suppose it can call the function inside the movie clip, but I fail to do this. I also try to place a button in the first frame of root timeline and add the code in the button:

on(release)
{
    _root.aMC.testFunc();
}

It can call the funtion successfully.
Someone may ask this question before, but I really confuse about this. Hope someone can help me.
```

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)\
**Post date:** [September 3, 2002, 11:02am UTC](https://forum.kirupa.com/t/function-call-problem/5157/2 "2002-09-03T11:02:10Z")

</div>

Sounds dodgy. Have you tried just

[COLOR=blue]testFunc();[/COLOR]?

I had a similar problem in a game. I used just the function name and it worked.

Hope it helps…

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)\
**Post date:** [September 3, 2002, 11:04am UTC](https://forum.kirupa.com/t/function-call-problem/5157/3 "2002-09-03T11:04:32Z")

</div>

Hi,

Why don’t u bring the function to the main timeline?  
This way u don’t only avoid this problem but have all the code neatly in the same place.

Cya

SHO

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)\
**Post date:** [September 3, 2002, 11:38am UTC](https://forum.kirupa.com/t/function-call-problem/5157/4 "2002-09-03T11:38:03Z")

</div>

Yeah, put your function in the \_root and call it with \_root.myFunc().

You can also make it global, but the \_root will do.

pom 🙂

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)\
**Post date:** [September 3, 2002, 12:02pm UTC](https://forum.kirupa.com/t/function-call-problem/5157/5 "2002-09-03T12:02:56Z")

</div>

the problem with your function, I believe, is that you’re calling the function before the movie declares it. Know what I mean? Also, you’re not pointing to the function inside the movie. So, for example, if you had three movies with the same function defined… which movie would you be calling?

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)\
**Post date:** [September 4, 2002, 2:54am UTC](https://forum.kirupa.com/t/function-call-problem/5157/6 "2002-09-04T02:54:34Z")

</div>

I agree Iammontoya said that I called the function before the movie declares. Then, is there any method or trick, so that I can call this kind of function inside a movie clip?
