# Help on global variables

**URL:** <https://forum.kirupa.com/t/help-on-global-variables/2557>\
**Category:** flash\
**Created:** [June 4, 2002, 10:08pm UTC](https://forum.kirupa.com/t/help-on-global-variables/2557 "2002-06-04T22:08:36Z")\
**Posts on this page:** 15\
**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:** [June 4, 2002, 10:08pm UTC](https://forum.kirupa.com/t/help-on-global-variables/2557/1 "2002-06-04T22:08:36Z")

</div>

Make things very simple, I need to pass variables between different movie clips (.swf’s) on my main movie. It seems as tho my variables are only local, not global, i just need to know how to initialize global variables, and how to use the global variables in my other swf’s. \r\rthanks alot, eric

---

<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 4, 2002, 10:22pm UTC](https://forum.kirupa.com/t/help-on-global-variables/2557/2 "2002-06-04T22:22:44Z")

</div>

precede your variables with \_global.

---

<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 4, 2002, 11:14pm UTC](https://forum.kirupa.com/t/help-on-global-variables/2557/3 "2002-06-04T23:14:05Z")

</div>

Ok so far example, if i had a variable char called “page1”, i would declare it global like… page1\_global ?

---

<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 4, 2002, 11:17pm UTC](https://forum.kirupa.com/t/help-on-global-variables/2557/4 "2002-06-04T23:17:07Z")

</div>

precede means before. \r\r\_global.page1

---

<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 4, 2002, 11:24pm UTC](https://forum.kirupa.com/t/help-on-global-variables/2557/5 "2002-06-04T23:24:32Z")

</div>

i have my variable before the \_global thing, but it’s still not correctly working. The variable in my main movie is not cooresponding with my other .swf movie. I don’t think it matters where i declare my variables, i have them declared on the main movie. any suggestions, or if u need more insite on what i exactly want just ask.

---

<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 4, 2002, 11:30pm UTC](https://forum.kirupa.com/t/help-on-global-variables/2557/6 "2002-06-04T23:30:18Z")

</div>

i’m not sure, the concept of global variables escapes me. someone else might know .there is a post in this section dealing with this…look for it…

---

<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 8, 2002, 1:54am UTC](https://forum.kirupa.com/t/help-on-global-variables/2557/7 "2002-06-08T01:54:03Z")

</div>

um… i know how to declare globals… thats easy… im not sure about accessing them… do you access them with \_root.varName or with \_global.varName again within the code… or just simply put varName… im not sure… anyone know? enlighten me please if you can… thanks…\r\r-scott

---

<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 8, 2002, 1:57am UTC](https://forum.kirupa.com/t/help-on-global-variables/2557/8 "2002-06-08T01:57:37Z")

</div>

i put \_global.varName it seemed to work for 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:** [June 8, 2002, 1:59am UTC](https://forum.kirupa.com/t/help-on-global-variables/2557/9 "2002-06-08T01:59:31Z")

</div>

\_global.varName will work but it’s not necessary. you can just go varName.\r\rthat’s what a global variable is. if you had to path it, it wouldn’t be global

---

<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 8, 2002, 11:50am UTC](https://forum.kirupa.com/t/help-on-global-variables/2557/10 "2002-06-08T11:50:03Z")

</div>

Ok, so In my Level0 SWF. the first File that comes up I have \_global.varName = function () {\r\rwhatever\r\r}\r\r\rbut when I use loadMovie and I bring in another SWF and I try\r\ron(press){\rvarName()\r}\r\rand \r\ron(press){\r\_global.varName()\r}\r\rand\r\ron(press){\r\_root.varName()\r}\r\rand\r\ron(press){\r\_parent.varName()\r}\r\r\rNone of them work…

---

<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 8, 2002, 3:36pm UTC](https://forum.kirupa.com/t/help-on-global-variables/2557/11 "2002-06-08T15:36:33Z")

</div>

i believe you’re mixing vars and events/functions here…?\rcan a variable be a function? can an apple be a computer? 😉

---

<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 8, 2002, 10:02pm UTC](https://forum.kirupa.com/t/help-on-global-variables/2557/12 "2002-06-08T22:02:48Z")

</div>

right, but when i do\r\rvarName = function(){\rwhatever\r}\r\rand then use \_root.varName()\r\rit calls the function…so i was wondering why global didn’t work…when I loaded SWFs in.

---

<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 8, 2002, 10:14pm UTC](https://forum.kirupa.com/t/help-on-global-variables/2557/13 "2002-06-08T22:14:03Z")

</div>

saying \r\rnVideo = function () {\rloadMovie(“sample.swf”, “wherever”)\r}\r\ris the same as\r\rfunction nVideo(){\rloadMovie(“sample.swf”, “wherever”)\r}\r\r\rand calling them is the same way. but it doesn’t work when I use \_global

---

<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 9, 2002, 12:30am UTC](https://forum.kirupa.com/t/help-on-global-variables/2557/14 "2002-06-09T00:30:19Z")

</div>

it works fine for me, with levels and targets … maybe something in your 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 9, 2002, 3:51am UTC](https://forum.kirupa.com/t/help-on-global-variables/2557/15 "2002-06-09T03:51:30Z")

</div>

maybe I’m just stupid. I’m sure thats it. I probly just typed in the wrong variable cuz now its workin…\r\rJubba = dumb
