Coding array and function

This code works fine for loading a pic into a created container and placed centered in a box_mc.
I am trying with no luck to have the same thing repeat itself x number of time.
My idea is:
array=[1, 2, 3];
var a = 0;
if (a< array.length){ a++;}
then apply the underneath code until a = array.length
changing all the 1 with the value of a, so to load each pic1,2 and 3 in different box_mc1, 2, 3 (still being centered).
:d:


[left]createEmptyMovieClip("container1", 1);[/left]
[left]function preload1(pic1) {[/left]
[left]     loaded = pic1.getBytesLoaded();[/left]
[left]     total = pic1.getBytesTotal();[/left]
[left]     if (loaded>=total && loaded>0) {[/left]
[left]          clearInterval(myinterval1);[/left]
[left]          w1 = pic1._width;[/left]
[left]          h1 = pic1._height;[/left]
[left]          trace(w1);[/left]
[left]          trace(h1);[/left]
[left]          container1._x = box_mc1._x+(box_mc1._width-w1)/2;[/left]
[left]          container1._y = box_mc1._y+(box_mc1._height-h1)/2;[/left]
[left]     }[/left]
[left]}[/left]
[left]loadMovie("pic1.jpg", "container1");[/left]
[left]myinterval1 = setInterval(preload1, 50, container1);

[/left]

PS:I did read many post about XML but would like to stick to AS. I am trying to learn one thing at the time.:to:
Thank you.