An array problem

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

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


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");
	};
}

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

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.

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

Try _parent.movieToLoad instead of this.movieToLoad

*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 :stuck_out_tongue:

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?

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

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

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” ,
“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,”_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.

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

Ahmeds method worked perfectly fine for me…

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

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.

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