# \[FMX\]Array question ! I think?

**URL:** https://forum.kirupa.com/t/fmx-array-question-i-think/119384
**Category:** Uncategorized
**Created:** [August 14, 2004, 5:47am UTC](https://forum.kirupa.com/t/fmx-array-question-i-think/119384 "2004-08-14T05:47:26Z")
**Posts on this page:** 14
**Page:** 1

<div class="post-metadata">

### Author: ![dboers](https://avatars.discourse-cdn.com/v4/letter/d/bbe5ce/32.png) [@dboers](https://forum.kirupa.com/u/dboers)
#### Post date: [August 14, 2004, 5:47am UTC](https://forum.kirupa.com/t/fmx-array-question-i-think/119384/1 "2004-08-14T05:47:26Z")

</div>

I have a movie with a changing background. I load external movies after one of the buttons is pressed and they appear al on a different place.The code to control my buttons is:

```auto
function setButton() {
for (var i in menuMc) {
if (menuMc*._name.substr(0, 4) == "btn_") {
clip = menuMc*;
clip.onRollOver = function() {
// etc etc etc......
}
}
}
}

```

I have a preloader for the external swf’s and that is working fine, but because of the changing backgroud it should appear on different x positions depending which btn\_ was pressed. Is there a possibilty to integrate something to make such thing work in my button function.  
[color=red]Example:[/color]  
When btn\_home is pressed the preloader should appear on \_x 425 and and when btn\_about is pressed on \_x 550 etc etc

Thanks in advance

---

<div class="post-metadata">

### Author: ![stringy](https://avatars.discourse-cdn.com/v4/letter/s/919ad9/32.png) [@stringy](https://forum.kirupa.com/u/stringy)
#### Post date: [August 14, 2004, 10:14am UTC](https://forum.kirupa.com/t/fmx-array-question-i-think/119384/2 "2004-08-14T10:14:34Z")

</div>

> [@dboers](#):
>
> I have a movie with a changing background. I load external movies after one of the buttons is pressed and they appear al on a different place.The code to control my buttons is:
> 
> ```auto
> function setButton() {
> for (var i in menuMc) {
> if (menuMc*._name.substr(0, 4) == "btn_") {
> clip = menuMc*;
> clip.onRollOver = function() {
> // etc etc etc......
> }
> }
> }
> }
> 
> ```
> 
> I have a preloader for the external swf’s and that is working fine, but because of the changing backgroud it should appear on different x positions depending which btn\_ was pressed. Is there a possibilty to integrate something to make such thing work in my button function.  
> [color=red]Example:[/color]  
> When btn\_home is pressed the preloader should appear on \_x 425 and and when btn\_about is pressed on \_x 550 etc etc
> 
> Thanks in advance

you may be able to get away with something like

clip.onRelease = function() {  
preloader\_mc.\_x = this.\_x;  
…  
}  
maybe having to add something to this.\_x depending upon reg points etc.

If instead, you decide that you want to use an array, then it should be very easy because of the ivar property you created before.  
put each position in order in the array  
myArray =[100,200,300,…]  
//the above is not in your function

clip.onRelease = function() {  
preloader\_mc.\_x = myArray[this.ivar-1];  
…  
}

---

<div class="post-metadata">

### Author: ![dboers](https://avatars.discourse-cdn.com/v4/letter/d/bbe5ce/32.png) [@dboers](https://forum.kirupa.com/u/dboers)
#### Post date: [August 14, 2004, 10:29am UTC](https://forum.kirupa.com/t/fmx-array-question-i-think/119384/3 "2004-08-14T10:29:35Z")

</div>

Hi stringy,

This is the main movie, that ivar part you made is in one of the external swf’s. So what should I do with the array ?

---

<div class="post-metadata">

### Author: ![stringy](https://avatars.discourse-cdn.com/v4/letter/s/919ad9/32.png) [@stringy](https://forum.kirupa.com/u/stringy)
#### Post date: [August 14, 2004, 10:55am UTC](https://forum.kirupa.com/t/fmx-array-question-i-think/119384/4 "2004-08-14T10:55:04Z")

</div>

> [@dboers](#):
>
> Hi stringy,
> 
> This is the main movie, that ivar part you made is in one of the external swf’s. So what should I do with the array ?

so is this for another set of buttons, just to load in different movies including the one you posted before? (just that the code you posted looks the same as the other movie)

---

<div class="post-metadata">

### Author: ![dboers](https://avatars.discourse-cdn.com/v4/letter/d/bbe5ce/32.png) [@dboers](https://forum.kirupa.com/u/dboers)
#### Post date: [August 14, 2004, 11:47am UTC](https://forum.kirupa.com/t/fmx-array-question-i-think/119384/5 "2004-08-14T11:47:21Z")

</div>

Yes this is the main movie, different movies, incl the one from the earlier threat, are loaded into this one.

---

<div class="post-metadata">

### Author: ![stringy](https://avatars.discourse-cdn.com/v4/letter/s/919ad9/32.png) [@stringy](https://forum.kirupa.com/u/stringy)
#### Post date: [August 14, 2004, 12:15pm UTC](https://forum.kirupa.com/t/fmx-array-question-i-think/119384/6 "2004-08-14T12:15:57Z")

</div>

> [@dboers](#):
>
> Yes this is the main movie, different movies, incl the one from the earlier threat, are loaded into this one.

well this is how i would do it.  
name your buttons btn0,btn1,btn2…  
movies to load movie0.swf,movie1.swf,movie2.swf…

numbut = 6 //number of buttons  
myArray =[100,200,300…] //\_x where you want preloader to appear  
for (var i = 0; i\<numbut; i++) {  
this[“btn”+i].ivar = i;  
this[“btn”+i].onPress = function() {  
preloader\_mc.\_x = myArray[this.ivar];  
loadMovie(“movie”+this.ivar+“.swf”, “container”);  
//start preloader function  
};  
}

---

<div class="post-metadata">

### Author: ![dboers](https://avatars.discourse-cdn.com/v4/letter/d/bbe5ce/32.png) [@dboers](https://forum.kirupa.com/u/dboers)
#### Post date: [August 14, 2004, 2:07pm UTC](https://forum.kirupa.com/t/fmx-array-question-i-think/119384/7 "2004-08-14T14:07:58Z")

</div>

Hi stringy,

My buttons are already called: btn\_home, btn\_service… etc. Does this make any different?

---

<div class="post-metadata">

### Author: ![stringy](https://avatars.discourse-cdn.com/v4/letter/s/919ad9/32.png) [@stringy](https://forum.kirupa.com/u/stringy)
#### Post date: [August 14, 2004, 2:28pm UTC](https://forum.kirupa.com/t/fmx-array-question-i-think/119384/8 "2004-08-14T14:28:01Z")

</div>

> [@dboers](#):
>
> Hi stringy,
> 
> My buttons are already called: btn\_home, btn\_service… etc. Does this make any different?

yes

If you are still using the for in loop and the buttons are contained in menuMC(again)  
myArray =[100,200,300…] //on the same timeline  
function setButton() {  
for (var i in menuMc) {  
if (menuMc\*._name.substr(0, 4) == "btn_") {  
clip = menuMc\*;  
clip.ivar = i

etc etc  
clip.onRelease = function() {  
preloader\_mc.\_x = myArray[this.ivar-1];  
…  
}

---

<div class="post-metadata">

### Author: ![dboers](https://avatars.discourse-cdn.com/v4/letter/d/bbe5ce/32.png) [@dboers](https://forum.kirupa.com/u/dboers)
#### Post date: [August 14, 2004, 2:35pm UTC](https://forum.kirupa.com/t/fmx-array-question-i-think/119384/9 "2004-08-14T14:35:34Z")

</div>

Thanks stringy 🙂

---

<div class="post-metadata">

### Author: ![dboers](https://avatars.discourse-cdn.com/v4/letter/d/bbe5ce/32.png) [@dboers](https://forum.kirupa.com/u/dboers)
#### Post date: [August 14, 2004, 4:26pm UTC](https://forum.kirupa.com/t/fmx-array-question-i-think/119384/10 "2004-08-14T16:26:04Z")

</div>

I was a bit to quik with my thank you. The buttons are indeed in menuMC and I placed the array with the different \_x positions at the same timeline I added clip.ivar = i; to the function. I even tried it with a seperate mc (test\_mc) what is visible all the time, but it isn’t working

---

<div class="post-metadata">

### Author: ![stringy](https://avatars.discourse-cdn.com/v4/letter/s/919ad9/32.png) [@stringy](https://forum.kirupa.com/u/stringy)
#### Post date: [August 14, 2004, 4:31pm UTC](https://forum.kirupa.com/t/fmx-array-question-i-think/119384/11 "2004-08-14T16:31:53Z")

</div>

> [@dboers](#):
>
> I was a bit to quik with my thank you. The buttons are indeed in menuMC and I placed the array with the different \_x positions at the same timeline I added clip.ivar = i; to the function. I even tried it with a seperate mc (test\_mc) what is visible all the time, but it isn’t working

try trace(this.ivar) inside clip.onRelease(){}  
is the preloader\_mc on the same timeline?

---

<div class="post-metadata">

### Author: ![dboers](https://avatars.discourse-cdn.com/v4/letter/d/bbe5ce/32.png) [@dboers](https://forum.kirupa.com/u/dboers)
#### Post date: [August 15, 2004, 4:40am UTC](https://forum.kirupa.com/t/fmx-array-question-i-think/119384/12 "2004-08-15T04:40:03Z")

</div>

The trace (this.ivar) gives btn\_home, btn\_service etc but nothing happens otherwise. I even tried it with a seperate mc because off-line (Ctrl-Enter) the preloader isn’t visible.

I have the file attached, maybe you see what i’m doing wrong

---

<div class="post-metadata">

### Author: ![stringy](https://avatars.discourse-cdn.com/v4/letter/s/919ad9/32.png) [@stringy](https://forum.kirupa.com/u/stringy)
#### Post date: [August 15, 2004, 8:56am UTC](https://forum.kirupa.com/t/fmx-array-question-i-think/119384/13 "2004-08-15T08:56:30Z")

</div>

> [@dboers](#):
>
> The trace (this.ivar) gives btn\_home, btn\_service etc but nothing happens otherwise. I even tried it with a seperate mc because off-line (Ctrl-Enter) the preloader isn’t visible.
> 
> I have the file attached, maybe you see what i’m doing wrong

Sorry, i`ve spent 20 mins or so looking at your file and i bet i`m more confused than you.

---

<div class="post-metadata">

### Author: ![dboers](https://avatars.discourse-cdn.com/v4/letter/d/bbe5ce/32.png) [@dboers](https://forum.kirupa.com/u/dboers)
#### Post date: [August 15, 2004, 9:10am UTC](https://forum.kirupa.com/t/fmx-array-question-i-think/119384/14 "2004-08-15T09:10:34Z")

</div>

Thanks anyway stringy.I will have to think about another solution then 🙂
