# How do I pass a variable from a button to a MC instance to tell it which SWF to Load?

**URL:** https://forum.kirupa.com/t/how-do-i-pass-a-variable-from-a-button-to-a-mc-instance-to-tell-it-which-swf-to-load/5031
**Category:** flash
**Created:** [August 29, 2002, 1:10pm UTC](https://forum.kirupa.com/t/how-do-i-pass-a-variable-from-a-button-to-a-mc-instance-to-tell-it-which-swf-to-load/5031 "2002-08-29T13:10:24Z")
**Posts on this page:** 8
**Page:** 1

<div class="post-metadata">

### Author: ![jOEL](https://avatars.discourse-cdn.com/v4/letter/j/b9bd4f/32.png) [@jOEL](https://forum.kirupa.com/u/jOEL)
#### Post date: [August 29, 2002, 1:10pm UTC](https://forum.kirupa.com/t/how-do-i-pass-a-variable-from-a-button-to-a-mc-instance-to-tell-it-which-swf-to-load/5031/1 "2002-08-29T13:10:24Z")

</div>

I’m sure this is pretty straightforward stuff, but I’m really just starting to get a handle on general actionscript - so any help would be tremendously appreciated.

Here’s what I’m trying to do:

I have a parent container movie that has several buttons on it. As it stands now the buttons trigger an instance of a MC on the main timeline to play using the “with” action (no biggie)

I would like to put a frame action in that MC instance that uses the “LoadMovieNum” action to load a particular external SWF movie into the container movie depending on which button the user clicked.

In theory I guess I need to somehow associate each button with it’s corresponding SWF child movie that is to be loaded (SetVariable?)

Then I need to pass that information to the MC instance in the main timeline that actually uses the LoadMovieNum command to load the SWF file.

Help anybody teach me how to do this, preferably without embarrassing me too much 🙂

Thanx in advance,

jOEL

---

<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: [August 29, 2002, 1:21pm UTC](https://forum.kirupa.com/t/how-do-i-pass-a-variable-from-a-button-to-a-mc-instance-to-tell-it-which-swf-to-load/5031/2 "2002-08-29T13:21:07Z")

</div>

You can store the data with your button an retrieve it with your clip rather than pass from 1 to another. The obvious container would be the \_root.

```auto
on (press){
  // do stuff
  // _root.myMovie="firstMovie.swf";
}

// then in your clip
loadMovieNum(_root.myMovie,level);

```

pom :asian:

---

<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: [August 29, 2002, 1:26pm UTC](https://forum.kirupa.com/t/how-do-i-pass-a-variable-from-a-button-to-a-mc-instance-to-tell-it-which-swf-to-load/5031/3 "2002-08-29T13:26:21Z")

</div>

Hey, J…

I believe all you need on a particular button…

on(release){  
if(\_root.loaded!=1){  
loadVariablesNum();  
\_root.loaded=1;  
}  
}

the \_root.loaded part is simply a switch, so you dont end up loading the same movie more than once. If you have more than one button (of course), your \_root.loaded value will change to 2 for button 2, 3 for button 3, etc…

Hope that helps.

---

<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: [August 29, 2002, 1:27pm UTC](https://forum.kirupa.com/t/how-do-i-pass-a-variable-from-a-button-to-a-mc-instance-to-tell-it-which-swf-to-load/5031/4 "2002-08-29T13:27:40Z")

</div>

well, Ilyas beat me to it again…

a million ways to do these things in Flash, Joel…

---

<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: [August 29, 2002, 1:32pm UTC](https://forum.kirupa.com/t/how-do-i-pass-a-variable-from-a-button-to-a-mc-instance-to-tell-it-which-swf-to-load/5031/5 "2002-08-29T13:32:10Z")

</div>

😛 Come on, Neo, you’re faster than this ![SIZE=1]for Matrix fans…[/SIZE]

---

<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: [August 29, 2002, 1:40pm UTC](https://forum.kirupa.com/t/how-do-i-pass-a-variable-from-a-button-to-a-mc-instance-to-tell-it-which-swf-to-load/5031/6 "2002-08-29T13:40:29Z")

</div>

let’s race!hehehehhe j/k It’s hard to this while on a conference call most of the day. Can you tell my conference call is boring?

RatS! I don’t remember if I took the blue pill or the red pill…

---

<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: [August 29, 2002, 1:48pm UTC](https://forum.kirupa.com/t/how-do-i-pass-a-variable-from-a-button-to-a-mc-instance-to-tell-it-which-swf-to-load/5031/7 "2002-08-29T13:48:19Z")

</div>

Thanx to you both!

I really appreciate it…I’ll get crackin on it right now.

---

<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: [August 29, 2002, 2:49pm UTC](https://forum.kirupa.com/t/how-do-i-pass-a-variable-from-a-button-to-a-mc-instance-to-tell-it-which-swf-to-load/5031/8 "2002-08-29T14:49:52Z")

</div>

First on the button i define a variable of “MovieClip” and set it to “theSetup.swf”

then I tell the MC instance “\_root.Doors” to play…like so:

on (release) {  
MovieClip = “TheSetup.swf”;  
with (\_root.Doors) {  
play();  
}  
}

Then in the MC instance “Doors” I have a frame action:

loadMovieNum(MovieClip value, \_root.MasterSwap);

“MasterSwap” is the MC that is to be swapped out with the newly loaded SWF file. How do I load the MovieClip value that was set when the mouse was pressed?
