# Array and function?

**URL:** <https://forum.kirupa.com/t/array-and-function/168357>\
**Category:** Uncategorized\
**Created:** [November 6, 2005, 2:14pm UTC](https://forum.kirupa.com/t/array-and-function/168357 "2005-11-06T14:14:46Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![onsitus](https://yyz1.discourse-cdn.com/flex011/user_avatar/forum.kirupa.com/onsitus/32/971_2.png) [@onsitus](https://forum.kirupa.com/u/onsitus)\
**Post date:** [November 6, 2005, 2:14pm UTC](https://forum.kirupa.com/t/array-and-function/168357/1 "2005-11-06T14:14:46Z")

</div>

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:

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

```

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.
