# How to pass variables values from movie clips to the main stage

**URL:** <https://forum.kirupa.com/t/how-to-pass-variables-values-from-movie-clips-to-the-main-stage/34473>\
**Category:** Uncategorized\
**Created:** [November 2, 2003, 11:47pm UTC](https://forum.kirupa.com/t/how-to-pass-variables-values-from-movie-clips-to-the-main-stage/34473 "2003-11-02T23:47:25Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![libman](https://avatars.discourse-cdn.com/v4/letter/l/50afbb/32.png) [@libman](https://forum.kirupa.com/u/libman)\
**Post date:** [November 2, 2003, 11:47pm UTC](https://forum.kirupa.com/t/how-to-pass-variables-values-from-movie-clips-to-the-main-stage/34473/1 "2003-11-02T23:47:25Z")

</div>

Hi all,

Newbie here. I have been studying up a storm but the learning curve is steep.

I’m perplexed by passing variables from a movie clip to the main stage.

I have a movie clip with an instance name mc1 on the main stage. In that movie clip I declared a variable

c = 5;

on the first frame inside the mc1 movie clip.

I thought I could access that variable inside mc1 from the main stage by placing this on the first frame of the main stage:

x = \_root.mc1.c;

Obviously I don’t understand what is going on in terms of scope of variables because I keep getting an undefined statement in my variable x.

Some insight would be appreciated.

* * *

Thanks,  
Greg

---

<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:** [November 3, 2003, 3:07am UTC](https://forum.kirupa.com/t/how-to-pass-variables-values-from-movie-clips-to-the-main-stage/34473/2 "2003-11-03T03:07:21Z")

</div>

Well, you’re targetting the variable correctly. Just make sure that the variable _c_ has been defined before you assign its value to the variable _x_. 🙂

---

<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:** [November 3, 2003, 10:58am UTC](https://forum.kirupa.com/t/how-to-pass-variables-values-from-movie-clips-to-the-main-stage/34473/3 "2003-11-03T10:58:21Z")

</div>

Thanks for the reply.

I did assign a value to c in the movie clip.

“Oddly” if I made my movie two frames long on the main stage then x did get the value from the movie clip. But if I didn’t make the movie on the main stage two frames long x remained undefined.

Sadly, I don’t get it. Obviously I’m not grasping something about the main time line inregards to the movie clip. I knoe the movie clip runs continuously.

Thanks,  
Greg

---

<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:** [November 3, 2003, 11:03am UTC](https://forum.kirupa.com/t/how-to-pass-variables-values-from-movie-clips-to-the-main-stage/34473/4 "2003-11-03T11:03:59Z")

</div>

The code in the main timeline is executed before the code in the movie clip! That’s why you get [font=courier new]undefined[/font] when you try to get its value whithin the same frame. 😛

… I suppose I should have said it in my previous reply.
