# Changing Function to load mc instead of movie using variables

**URL:** https://forum.kirupa.com/t/changing-function-to-load-mc-instead-of-movie-using-variables/60001
**Category:** flash
**Created:** [August 5, 2004, 3:21pm UTC](https://forum.kirupa.com/t/changing-function-to-load-mc-instead-of-movie-using-variables/60001 "2004-08-05T15:21:49Z")
**Posts on this page:** 3
**Page:** 1

<div class="post-metadata">

### Author: ![jillymo](https://avatars.discourse-cdn.com/v4/letter/j/5f9b8f/32.png) [@jillymo](https://forum.kirupa.com/u/jillymo)
#### Post date: [August 5, 2004, 3:21pm UTC](https://forum.kirupa.com/t/changing-function-to-load-mc-instead-of-movie-using-variables/60001/1 "2004-08-05T15:21:49Z")

</div>

I have a movie set up with states (as in United States) as clickable mc’s. They are currently set so that when clicked on, a new movie is loaded into a container mc and the state is then deactivated, or can no longer be clicked.

I would like to change this so that rather than loading outside swf’s it would load mc’s so I can keep everything within the same movie. How would I alter the current code to allow for this?

Current code:  
[COLOR=Navy][SIZE=1]//mcs labelled mystate0,mystate1 etc  
//swfs to load called movie0.swf,movie1.swf etc  
createEmptyMovieClip(“container”, 5);  
for (var i = 0; i\<52; i++) {  
this[“myState”+i].ivar = i;  
this[“myState”+i].onPress = function() {  
loadMovie(“movie”+this.ivar+".swf", “container”);  
this.enabled = false;  
};  
}[/SIZE][/COLOR]

I know how to use attachMovie to load a mc, rather than the loadMovie to load an swf, but not sure how to work in the variables. I was planning on calling the mc’s mystate0question, mystate1question, etc.

---

<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 5, 2004, 3:43pm UTC](https://forum.kirupa.com/t/changing-function-to-load-mc-instead-of-movie-using-variables/60001/2 "2004-08-05T15:43:27Z")

</div>

Ack, I forgot to set the linkage to export the mc for as, now I just need to know how to set it up with the mc being loaded as a variable…

so, I have changed  
[COLOR=Navy][SIZE=1]//mcs labelled mystate0,mystate1 etc  
//swfs to load called movie0.swf,movie1.swf etc  
createEmptyMovieClip(“container”, 5);  
for (var i = 0; i\<52; i++) {  
this[“myState”+i].ivar = i;  
this[“myState”+i].onPress = function() {  
[COLOR=DarkRed]loadMovie(“movie”+this.ivar+".swf", “container”);[/COLOR]

this.enabled = false;  
};[/SIZE][/COLOR]

to

[COLOR=Navy][SIZE=1]//mcs labelled mystate0,mystate1 etc  
//swfs to load called movie0.swf,movie1.swf etc  
createEmptyMovieClip(“container”, 5);  
for (var i = 0; i\<52; i++) {  
this[“myState”+i].ivar = i;  
this[“myState”+i].onPress = function() {  
[COLOR=DarkRed]\_root.container.attachMovie(“mystate0question”,“question”,10);[/COLOR]this.enabled = false;  
};  
}[/SIZE][/COLOR]

---

<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 5, 2004, 5:13pm UTC](https://forum.kirupa.com/t/changing-function-to-load-mc-instead-of-movie-using-variables/60001/3 "2004-08-05T17:13:47Z")

</div>

[http://groups.yahoo.com/group/flashexamples/](http://groups.yahoo.com/group/flashexamples/)
