# Calling a function within a movie clip

**URL:** <https://forum.kirupa.com/t/calling-a-function-within-a-movie-clip/1740>\
**Category:** flash\
**Created:** [May 31, 2002, 1:22pm UTC](https://forum.kirupa.com/t/calling-a-function-within-a-movie-clip/1740 "2002-05-31T13:22:58Z")\
**Posts on this page:** 5\
**Page:** 1

<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:** [May 31, 2002, 1:22pm UTC](https://forum.kirupa.com/t/calling-a-function-within-a-movie-clip/1740/1 "2002-05-31T13:22:58Z")

</div>

On my main timeline, I have a movie clip located on frame 3. Inside that movie clip I have a function. My goal is to call that function from frame 1 of my main timeline.

I have tried the following code with absolutely no results:

\_root.myMovieClipName.myFunctionName();

I’ve also tried:

\_level0.myMovieClipName.myFunctionName();

Any suggestions?

---

<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:** [May 31, 2002, 1:46pm UTC](https://forum.kirupa.com/t/calling-a-function-within-a-movie-clip/1740/2 "2002-05-31T13:46:57Z")

</div>

I could be wrong here… but your function will only exist on the “on handler”.

Why not create your function in a frame of the main timeline? That way it will always be available to all objects in your scene.

---

<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:** [May 31, 2002, 3:58pm UTC](https://forum.kirupa.com/t/calling-a-function-within-a-movie-clip/1740/3 "2002-05-31T15:58:54Z")

</div>

It actually gets kind of complicated, but basically it needs to stay in my movie clip because as part of my function I am evaluating a variable and then moving on to a different frame in the movie clip.

But what did you mean by it only existing on the “on handler?”

I can easily jump from somewhere in a movie clip to function on my main timeline, and according to everything I’ve read, I should be able to jump from my main timeline to a function in a movie clip. I just can’t seem to determine what is going wrong.

I welcome any suggestions.

---

<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:** [June 1, 2002, 4:51am UTC](https://forum.kirupa.com/t/calling-a-function-within-a-movie-clip/1740/4 "2002-06-01T04:51:29Z")

</div>

I may not be right either… but as far as I know… you can only do this if the movie clip that contains the function is in existence when you attempt to call the function.

---

<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:** [June 2, 2002, 3:00pm UTC](https://forum.kirupa.com/t/calling-a-function-within-a-movie-clip/1740/5 "2002-06-02T15:00:33Z")

</div>

Exactly, Upu. You can’t do that because the function dosn’t exist at the time you’re trying to use it. But what you can do though is define a prototype in frame 1 and then call it. Or even a function that you can call with \_root.function.

pom 0]
