# An array problem

**URL:** <https://forum.kirupa.com/t/an-array-problem/23435>\
**Category:** Uncategorized\
**Created:** [June 18, 2003, 12:42am UTC](https://forum.kirupa.com/t/an-array-problem/23435 "2003-06-18T00:42:55Z")\
**Posts on this page:** 13\
**Page:** 1

<div class="post-metadata">

**Author:** ![zephn](https://avatars.discourse-cdn.com/v4/letter/z/5f8ce5/32.png) [@zephn](https://forum.kirupa.com/u/zephn)\
**Post date:** [June 18, 2003, 12:42am UTC](https://forum.kirupa.com/t/an-array-problem/23435/1 "2003-06-18T00:42:55Z")

</div>

I have a menu array that has a few of links

var menuItems = [ “Rental Rates”,  
“Catering Package”,  
“London Bar Menu”,  
“Floor Plan Level 1”,  
“Floor Plan Level 2”];

var pdf = [ “components/cateringpackage.pdf”,  
“components/floorplan1stlevel.pdf”,  
“components/floorplan2ndlevel.pdf”,  
“components/londonbarmenu.pdf”,  
“components/rentalrates.pdf”];

for (i=0; i\<menuItems.length; i++) {  
mc = container.dynamicButton.duplicateMovieClip(“button”+i, i);  
mc.menuLabel.text = menuItems\*;  
mc.\_y = i\*(mc.\_height-1);  
mc.movieToLoad = pdf\*;  
mc.actualButton.onPress = function() {  
getURL(pdf,"\_blank");  
};  
}

when I click on a button it pops up this webaddress. You’ll notice it is all the array options in one string. any ideas why that is?

C:\Documents%20and%20Settings\Zephn\Desktop\Thisislondon\components\cateringpackage.pdf,components\floorplan1stlevel.pdf,components\floorplan2ndlevel.pdf,components\londonbarmenu.pdf,components\rentalrates.pdf

---

<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:** [June 18, 2003, 1:57am UTC](https://forum.kirupa.com/t/an-array-problem/23435/2 "2003-06-18T01:57:00Z")

</div>

the loop you have is weird, does it actually work? try this anyways

```auto

menuItems = [
"Rental Rates", 
"Catering Package", 
"London Bar Menu", 
"Floor Plan Level 1", 
"Floor Plan Level 2"
];

pdf = [
"components/cateringpackage.pdf", 
"components/floorplan1stlevel.pdf", 
"components/floorplan2ndlevel.pdf", 
"components/londonbarmenu.pdf", 
"components/rentalrates.pdf"
];

for (i=0; i<5; i++) {
	mc = container.dynamicButton.duplicateMovieClip("button"+i, ++depth);
	mc.menuLabel.text = menuItems*;
	mc._y = i*(mc._height-1);
	mc.actualButton.pdf = pdf*;
	mc.actualButton.onPress = function() {
		getURL(this.pdf, "_blank");
	};
}

```

---

<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:** [June 18, 2003, 2:10am UTC](https://forum.kirupa.com/t/an-array-problem/23435/3 "2003-06-18T02:10:15Z")

</div>

ahmed: His loop is weird because he chose not to use the Actionscript formatting tags :sigh:

And the problem lies here…

[AS]mc.movieToLoad = pdf\*;  
mc.actualButton.onPress = function() {  
getURL(pdf,"\_blank");  
};[/AS]

getURL(pdf, “\_blank”) will return all the items in the pdf array.

What you REALLY want is to change “pdf” to this.movieToLoad

---

<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:** [June 18, 2003, 3:09am UTC](https://forum.kirupa.com/t/an-array-problem/23435/4 "2003-06-18T03:09:40Z")

</div>

oh oh I’m beginning o see the obvious problem but not the solution… let me explain what I want to hve happen. Sometimes when m,aking a post I forget to put the end result…

I want to have each button open a new window and load a url (or in this case a pdf) into it.

---

<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:** [June 18, 2003, 3:17am UTC](https://forum.kirupa.com/t/an-array-problem/23435/5 "2003-06-18T03:17:35Z")

</div>

so I changed  
getURL(pdf,"\_blank");  
to  
getURL(this.movieToLoad,"\_blank");  
however no new window opens up and nothing else happen either.

---

<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:** [June 18, 2003, 3:52am UTC](https://forum.kirupa.com/t/an-array-problem/23435/6 "2003-06-18T03:52:22Z")

</div>

Try \_parent.movieToLoad instead of this.movieToLoad

---

<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:** [June 18, 2003, 4:15am UTC](https://forum.kirupa.com/t/an-array-problem/23435/7 "2003-06-18T04:15:56Z")

</div>

> \*Originally posted by lostinbeta \*  
> **ahmed: His loop is weird because he chose not to use the Actionscript formatting tags :sigh:**  
> lol!:P, i honestly thought it’s a different kind of loop that i haven’t dealt with yet 😛

anywho, in the script i gave you, i assigned a variable to the button movieclip which is equivelent to the relative array entry , and it’s then called on the onPress event… did that not work?

```auto
mc.actualButton.pdf = pdf*;
        mc.actualButton.onPress = function() {
                getURL(this.pdf, "_blank");
        };
}

```

---

<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:** [June 18, 2003, 4:54am UTC](https://forum.kirupa.com/t/an-array-problem/23435/8 "2003-06-18T04:54:56Z")

</div>

unfortunatly it did not ahmed… would it be best if I posted the swf? … here I’ll do that in the post option

---

<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:** [June 18, 2003, 4:57am UTC](https://forum.kirupa.com/t/an-array-problem/23435/9 "2003-06-18T04:57:42Z")

</div>

oops i mean fla

heres the current fla with the code

var menuItems = [  
“Rental Rates”,  
“Catering Package”,  
“London Bar Menu”,  
“Floor Plan Level 1”,  
“Floor Plan Level 2”];

var pdf = [“[http://www.thisislondonclub.com/components/cateringpackage.pdf](http://www.thisislondonclub.com/components/cateringpackage.pdf)” ,  
“components/floorplan1stlevel.html”,  
“components/floorplan2ndlevel.pdf”,  
“components/londonbarmenu.pdf”,  
“components/rentalrates.pdf”];

for (i=0; i\<menuItems.length; i++) {  
mc = container.dynamicButton.duplicateMovieClip(“button”+i, i);  
mc.menuLabel.text = menuItems\*;  
mc.\_y = i\*(mc.\_height-1);  
mc.movieToLoad = pdf\*;  
mc.actualButton.onPress = function() {  
getURL(this.movietoload,"\_blank");  
};  
}

I tried chacing this string as an experiment  
getURL(this.movietoload,"\_blank");  
to  
getURL(“[http://www.hotmail.com](http://www.hotmail.com),”\_blank");

and it worked in making all the buttons go to hotmail

so the problem seems to be how I’m expressing the array in combination with get url.

---

<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:** [June 18, 2003, 4:58am UTC](https://forum.kirupa.com/t/an-array-problem/23435/10 "2003-06-18T04:58:35Z")

</div>

keep in mind the links at the moment are mixed as I have been playing around with them

---

<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:** [June 18, 2003, 5:04am UTC](https://forum.kirupa.com/t/an-array-problem/23435/11 "2003-06-18T05:04:45Z")

</div>

Ahmeds method worked perfectly fine for me…

[AS]mc.actualButton.movieToLoad = pdf\*;  
mc.actualButton.onPress = function() {  
getURL(this.movieToLoad, “\_blank”);  
};[/AS]

---

<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:** [June 18, 2003, 11:26am UTC](https://forum.kirupa.com/t/an-array-problem/23435/12 "2003-06-18T11:26:10Z")

</div>

weird now it does… thanks guys… maybe I cut out an extra line or somthing. Is it customary to post the end fla for people to use on these forums? I can do that if you guys like.

---

<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:** [June 18, 2003, 7:14pm UTC](https://forum.kirupa.com/t/an-array-problem/23435/13 "2003-06-18T19:14:46Z")

</div>

It’s optional really, you can if you want, it may help someone, but you don’t have to.
