# Variable Passing

**URL:** https://forum.kirupa.com/t/variable-passing/65967
**Category:** programming
**Created:** [October 1, 2004, 1:17am UTC](https://forum.kirupa.com/t/variable-passing/65967 "2004-10-01T01:17:27Z")
**Posts on this page:** 7
**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: [October 1, 2004, 1:17am UTC](https://forum.kirupa.com/t/variable-passing/65967/1 "2004-10-01T01:17:27Z")

</div>

Hey,

I have used the kirupa tutorial for passing variables to a flash file, which in theory all makes sense, however my code only appears to partially work… this if from frame 1 of the movie:

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 = “intro2.swf”;  
}

It’ll load image3.swf if i use myfile.swf?movie=3 but any other variables will result in the else running (even no value). Any idea what is going on here?

Cheers,  
dft.

---

<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: [October 1, 2004, 1:23am UTC](https://forum.kirupa.com/t/variable-passing/65967/2 "2004-10-01T01:23:03Z")

</div>

Ok, some changes…

I removed the else, and now image1.swf will load, but still not image2 (image3 still works). It auto loads the intro2.swf, even without knowing where it is.

I think I need to play with this some more 🙂

---

<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: [October 1, 2004, 1:28am UTC](https://forum.kirupa.com/t/variable-passing/65967/3 "2004-10-01T01:28:23Z")

</div>

fixed it. haha, go team me. code is below.

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

---

<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: [October 1, 2004, 1:34am UTC](https://forum.kirupa.com/t/variable-passing/65967/4 "2004-10-01T01:34:26Z")

</div>

how about a more streamlined approach?

if (movie != null) {  
\_root.section = “image”+movie+".swf";  
}  
else {  
\_root.section = intro2.swf;  
}

btw in the long run, a relative reference is a lot more efficient than an absolute, so ie. \_parent.\_parent.section (or whatever) instead of \_root.section

---

<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: [October 1, 2004, 1:55am UTC](https://forum.kirupa.com/t/variable-passing/65967/5 "2004-10-01T01:55:25Z")

</div>

ahh, nice… that’s cool. Thankyou.

---

<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: [October 1, 2004, 6:13am UTC](https://forum.kirupa.com/t/variable-passing/65967/6 "2004-10-01T06:13:31Z")

</div>

can u please post the tutorial url i need it urgent

---

<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: [October 1, 2004, 6:16am UTC](https://forum.kirupa.com/t/variable-passing/65967/7 "2004-10-01T06:16:30Z")

</div>

[http://www.kirupa.com/developer/actionscript/tricks/passingvariables.htm](http://www.kirupa.com/developer/actionscript/tricks/passingvariables.htm)
