# Passing Variables to Flash

**URL:** <https://forum.kirupa.com/t/passing-variables-to-flash/64900>\
**Category:** flash\
**Created:** [September 21, 2004, 4:55am UTC](https://forum.kirupa.com/t/passing-variables-to-flash/64900 "2004-09-21T04:55:17Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![dreeft](https://avatars.discourse-cdn.com/v4/letter/d/5f9b8f/32.png) [@dreeft](https://forum.kirupa.com/u/dreeft)\
**Post date:** [September 21, 2004, 4:55am UTC](https://forum.kirupa.com/t/passing-variables-to-flash/64900/1 "2004-09-21T04:55:17Z")

</div>

Hey Everybody,

I’m new here, but I’ve used the site many times for flash research, so I thought I’d do the right thing and join up.

I’ve been having an issue using the [Passing Variables to Flash tutorial inside a single frame flash document. The document itself contains a MC that works using the [url=“http://www.kirupa.com/developer/mx/preloader\_transition.htm”]Preloader & Transition of Dynamic Files](http://www.kirupa.com/developer/actionscript/tricks/passingvariables.htm) tutorial. I have used the \_x and \_y properties to movie an image Inside each of the preloaded movies.

The code for the first frame of the document I am trying to pass the variable to, is as follows:

if (movie=="" or movie==1) {  
\_root.section = “image1.swf”;  
}  
if (movie==2) {  
\_root.section = “image2.swf”;  
}  
if (movie==3) {  
\_root.section = “image3.swf”;  
}  
else {  
\_root.section = “image3.swf”;  
}

However, when the movie is run, the code will always go to the else, no matter what the parameter specified in the URL is. I can only assume this has something to do with the fact that it is looping on the first frame.

Thanks in advance,

dreeft.

---

<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 21, 2004, 6:39am UTC](https://forum.kirupa.com/t/passing-variables-to-flash/64900/2 "2004-09-21T06:39:31Z")

</div>

> [@dreeft](#):
>
> Hey Everybody,
> 
> I’m new here, but I’ve used the site many times for flash research, so I thought I’d do the right thing and join up.
> 
> I’ve been having an issue using the [Passing Variables to Flash tutorial inside a single frame flash document. The document itself contains a MC that works using the [url=“http://www.kirupa.com/developer/mx/preloader\_transition.htm”]Preloader & Transition of Dynamic Files](http://www.kirupa.com/developer/actionscript/tricks/passingvariables.htm) tutorial. I have used the \_x and \_y properties to movie an image Inside each of the preloaded movies.
> 
> The code for the first frame of the document I am trying to pass the variable to, is as follows:
> 
> if (movie==“” or movie==1) {  
> \_root.section = “image1.swf”;  
> }  
> if (movie==2) {  
> \_root.section = “image2.swf”;  
> }  
> if (movie==3) {  
> \_root.section = “image3.swf”;  
> }  
> else {  
> \_root.section = “image3.swf”;  
> }
> 
> However, when the movie is run, the code will always go to the else, no matter what the parameter specified in the URL is. I can only assume this has something to do with the fact that it is looping on the first frame.
> 
> Thanks in advance,
> 
> dreeft.

Hi

Your code looks ok to me,

if (movie==“” or movie==1) {  
\_root.section = “image1.swf”;  
}else if (movie==2) {  
\_root.section = “image2.swf”;  
}else if (movie==3) {  
\_root.section = “image3.swf”;  
} else {  
\_root.section = “image3.swf”;  
}

try else if…i know this is not the smartest answer… 😱  
but u have to debug what value is their in variable movie. By looking at ur code it seems u might have written the script inside MC. If my guess is right  
then check varible movie. Is it declared on stage or in MC.

* * *

aShIsH

---

<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 21, 2004, 6:52am UTC](https://forum.kirupa.com/t/passing-variables-to-flash/64900/3 "2004-09-21T06:52:18Z")

</div>

I tried it with the else if’s, didn’t make any difference.

The script is inside the first frame of the scene (the stage). The variable movie is not returning anything, as far as I can see. I tried outputting the variable to a text box, and it gave me nothing.

Any ideas?

---

<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 21, 2004, 7:45am UTC](https://forum.kirupa.com/t/passing-variables-to-flash/64900/4 "2004-09-21T07:45:45Z")

</div>

if movie is a variable name, try this

```auto

if (_root.movie=="" or _root.movie==1) {
_root.section = "image1.swf";
}
if (_root.movie==2) {
_root.section = "image2.swf";
}
if (_root.movie==3) {
_root.section = "image3.swf";
}
else {
_root.section = "image3.swf";
}

```

or check the value of movie by,  
trace(movie);

---

<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 22, 2004, 1:03am UTC](https://forum.kirupa.com/t/passing-variables-to-flash/64900/5 "2004-09-22T01:03:22Z")

</div>

I’m getting “undefined” from the trace, inside flash. But that’ll be because it’s not passing anything to it when it runs. Can I add command line arguments inside flash? (It’s also not giving me the option of running as HTML, which I thought was weird).

The code didn’t make any difference 😕

---

<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 24, 2004, 5:28am UTC](https://forum.kirupa.com/t/passing-variables-to-flash/64900/6 "2004-09-24T05:28:50Z")

</div>

Hm… can I bump this? 😃
