I have an array of 49 images (.jpg). I need to write a function that will load them each into their own mc. I want to just write code to create the 49 empty clips, rather than having to create them all.
I have been trying to use a for loop. The loop would go through 49 times and create a clip each time and then load it with the next image in the array. I also want to be able to give each clip a unique x and y position, which I hope to do by using the loops counter and multiplying by a value. My code is not working at all. I was hoping that someone could help with a code for this.
var pathToPics = "bridgeParts/";
pArray = new Array();
pArray = ["image0.jpg", "image1.jpg", "image6.jpg", "image7.jpg", "image8.jpg", "image9.jpg"];
function loadImages() {
for (j=0; j<pArray.length; j++) {
new_mc = this.createEmptyMovieClip("emptyClip"+j, j);
new_mc.loadMovie(pathToPics+pArray[j]);
//if you want 49 pictures I've doubts about the next line
//the last picture will have a _x=11040 ????
new_mc._x = j*230;
}
}
loadImages();
Thanks Scotty! I got it working perfectly. I knew I wouldn’t be able to do that 230*49 thing, but I also knew I could change that stuff. I ended up having a bunch of “if” statements and put the pics on 7 different rows. Thanks a lot for your help.
good call, paradox! i like that code. i figured there was a better way than to write about 6 “if” statements. i will definitely keep that in mind in the future.