-
Array of links to buttons
This has probably been asked a million times, but anyway, I'm trying to do an array of links that'll be inserted to each of the buttons.
Here's what I did:
I already have 5 buttons on the stage, labeled s1 - s5.
Code:
linkArray = new Array();
linkArray = ["http://www.link1.html", "http://www.link2.html", "http://www.link3.html", "http://www.link4.html", "http://www.link5.html"];
var amount = 5;
for (i=1; i<=amount; i++) {
button = this["s"+i];
button.i = i;
button.onRelease = function() { getURL(linkArray[i],"_blank");
}
}
When I try to click on a button, the URL doesn't get passed at the onRelease instance, but a new window opens nonetheless.
Am I missing something here? Please help. Thanks!
-
Senior Member
Change this bit:
getURL(linkArray[i],"_blank");
to this:
getURL(linkArray[this.i],"_blank");
Otherwise, it doesn't know which i you are refering to when the function is called.
-
Hey,
It works now. Thanks much!
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|