-
for Loop?
Hello...
I am creating a client website.
I have several thumnails on the wesbite which I'm linking to the larger image through loadMovie();, using code like this:
Code:
thumb1.onRelease = function() {
unloadMovie(_root.pic);
_root.pic.loadMovie("images/1.jpg");
_root.black._visible = true;
new Tween(_root.black, "_alpha", Regular.easeInOut, 0, 70, 1, true);
}
Now, I have 60 thumbnails. Is there a way to do this using a for loop so I don't have to copy and paste the same action for all 60.
The images and thumb names are the same...i.e. thumb1 links to 1.jpg and thumb60 links to 60.jpg.
Thanks
-
Now I didn't test this but this looks correct to me.
By making i<= a variable you can just change the totalImages var or, if you want to get crazy with it, set it dynamically.
the variable thumb = _root: im assuming mc thumb is on the root timeline. This may need to be adjusted.
Code:
var totalImages = 60;
for (var i = 0; i<=totalImages; i++) {
var thumb = _root["thumb"+i];
thumb.onRelease = function() {
unloadMovie(_root.pic);
_root.pic.loadMovie("images/"+i+".jpg");
_root.black._visible = true;
new Tween(_root.black, "_alpha", Regular.easeInOut, 0, 70, 1, true);
}
}