Groups | Blog | Home
all groups > flash actionscript > october 2004 >

flash actionscript : URL strings constructed from array objects


nab137
10/21/2004 11:07:57 PM
I am interested in creating URL strings by using the names of the objects in an
array. For example, I have an array
[1 2 3 4 5] and have looped through the array to create one instance of each
object on the page. Now, I want to create a link when each object in the array
is clicked
on(press){
getURL(1.html);
}
on(press){
getURL(2.html);
}
etc.
Is there any way to write this into the loop so that the getURL statements are
automatically assigned to each object in the array?

_jrh_
10/21/2004 11:19:46 PM
Put this in the loop:

myArray = ["1","2","3","4"];
for (k=0;k<myArray.length;k++) {
// assuming you created a myBtn instance for each item
myBtn.onPress = function() {
getURL(myArray[k]+".html");
}
}
AddThis Social Bookmark Button