I have an array of movie clips and an array of links. I want to assign the links to the movie clips. It works fine without a loop. The working code follows. But it says the file is undefined when I attempt to replace the last 9 lines of code with:
for (m=0;m<3;m++) {
movieArray[m].onRelease = function (m) {
getURL(linksArray[m]);
}
}
Here is the working code. How do I use a loop for the last block? – the real project has at least 24 movies and links.
//Make a batch of empty movie clips
_root.holder1_mc.createEmptyMovieClip(“imageHolder1_mc”,1);
_root.holder1_mc.imageHolder1_mc.createEmptyMovieClip(“image”,51)
_root.holder1_mc.createEmptyMovieClip(“imageHolder2_mc”,2);
_root.holder1_mc.imageHolder2_mc.createEmptyMovieClip(“image”,52)
_root.holder1_mc.createEmptyMovieClip(“imageHolder3_mc”,3);
_root.holder1_mc.imageHolder3_mc.createEmptyMovieClip(“image”,53)
//put images in the movie clips
_root.holder1_mc.imageHolder1_mc.image.loadMovie(“hmr/thumbs/abc001.jpg”)
_root.holder1_mc.imageHolder2_mc.image.loadMovie(“hmr/thumbs/abc002.jpg”)
_root.holder1_mc.imageHolder3_mc.image.loadMovie(“hmr/thumbs/abc003.jpg”)
//position the movie clips
_root.holder1_mc.imageHolder1_mc._x=7;
_root.holder1_mc.imageHolder2_mc._x=64;
_root.holder1_mc.imageHolder3_mc._x=121;
//Array of links (in the real project these are read from an external file)
_global.linksArray = new Array();
linksArray = [“http://www.tonybarre.com/matt",“http://www.tonybarre.com/travis”,"http://www.tonybarre.com/melissa”];
//Array of movie clips (in the real project I create these with a loop)
_global.movieArray = new Array();
movieArray = [_root.holder1_mc.imageHolder1_mc, _root.holder1_mc.imageHolder2_mc, _root.holder1_mc.imageHolder3_mc]
//Assign the links to the corresponding movie clips (I want to put the following code into a loop
movieArray[0].onRelease = function () {
getURL(linksArray[0]);
}
movieArray[1].onRelease = function () {
getURL(linksArray[1]);
}
movieArray[2].onRelease = function () {
getURL(linksArray[2]);
}