Loading images problem

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.

Thanks in advance

How far did you come? (post a fla/code)

scotty(-:

Here is what I have right now. I know there is a lot wrong with it and I have tried changing a lot of things. Thanks for helping out!

pathToPics = “bridgeParts/”;

Array.prototype.loadImages=function(){
for(j=0;j<this.length;j++){
this.createEmptyMovieClip (“emptyClip”+j, j);
loadMovie(pathToPics.arr1[j], “movieclip” +j);
“movieclip”+j._x = j*230

}

Fill the pArray with your pictures;)

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();

scotty(-:

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.

instead of if statements use something like this:
[AS]
_root.numOfItemsPerRow = 10;
_root.xSpacing = 10;
_root.ySpacing = 10;
_root.numOfPics = 49;
for (i=0; i<_root.numOfPics; i++) {
new_mc = this.createEmptyMovieClip (“emptyClip”+i, i);
new_mc.loadMovie(pathToPics.arr1*);
row = Math.floor(i/_root.numOfItemsPerRow);
new_mc._x = 30+(_root.xSpacingi)-((_root.xSpacing_root.numOfItemsPerRow)row);
new_mc._y = 30+(_root.ySpacing
row);
}
[/AS]

no problem, afmaury:thumb:
=)paradox244=)

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.