# Controlling time intervals

**URL:** <https://forum.kirupa.com/t/controlling-time-intervals/201290>\
**Category:** Uncategorized\
**Created:** [September 20, 2006, 4:24am UTC](https://forum.kirupa.com/t/controlling-time-intervals/201290 "2006-09-20T04:24:27Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![yanuss](https://avatars.discourse-cdn.com/v4/letter/y/8e8cbc/32.png) [@yanuss](https://forum.kirupa.com/u/yanuss)\
**Post date:** [September 20, 2006, 4:24am UTC](https://forum.kirupa.com/t/controlling-time-intervals/201290/1 "2006-09-20T04:24:27Z")

</div>

Sup peeps. Would be much appreciated if yous could help me with this code. It isn’t mine, sorry dont know who the author is.

Basically I need an the images to play automatically after 9 seconds. I was messing around with the setTimeout() function but this code structure didnt like it.

> 

spacing = 4;  
containerMC.\_alpha = 0;  
pArray = new Array();  
pictArray = new Array();

MovieClip.prototype.loadPic = function(pic)  
{  
this.\_alpha = 0;  
this.loadMovie(pArray[pic]);  
this.\_parent.onEnterFrame = function()  
{  
picloadtxt.\_visible = 1;  
var amount:Number = containerMC.getBytesLoaded() / containerMC.getBytesTotal() \* 100;  
this.loadingtxt = Math.round(amount)+“%”;

```
    var t = containerMC.getBytesTotal(), l = containerMC.getBytesLoaded();
    bar._visible = 1;
    per = Math.round((l/t)*100);
    
    if (t != 0 && Math.round(l/t) == 1 && containerMC._width != 0) 
     {
        var w = containerMC._width+spacing, h = containerMC._height+spacing;
        border.resizeMe(w, h);
        bar._visible = 0;
        picloadtxt._visible = 0;
        delete this.onEnterFrame;
      } 
     else { bar._width = per; }
};

```

};

MovieClip.prototype.resizeMe = function(w, h, pic)  
{  
var speed = 6;  
this.onEnterFrame = function()  
{  
this.\_width += (w-this.\_width)/speed;  
this.\_height += (h-this.\_height)/speed;  
if (Math.abs(this.\_width-w)\<1 && Math.abs(this.\_height-h)\<1)  
{  
this.\_width = w;  
this.\_height = h;  
containerMC.\_x = this.\_x-this.\_width/2+spacing/2;  
containerMC.\_y = this.\_y-this.\_height/2+spacing/2;  
containerMC.\_alpha = 100;  
delete this.onEnterFrame;  
}  
};  
};

my\_xml = new XML();  
my\_xml.ignoreWhite = true;  
my\_xml.onLoad = function(success)  
{  
if (success)  
{  
for (var i = 0; i\<this.firstChild.childNodes.length; i++) {  
pictArray.push(this.firstChild.childNodes\*.attributes.thumb);  
pArray.push(this.firstChild.childNodes\*.attributes.image);  
}  
}  
delay = setInterval(makeMenu, 100);  
};

my\_xml.load(“gallery\_bridal.xml”);  
var menu = this.createEmptyMovieClip(“menu\_tot”, 99);  
menu.setMask(mask);  
var sub\_menu = menu.createEmptyMovieClip(“menu”, 100);  
var p = 0;  
var q = 0;  
var loadper = 0;  
var picID = 1;

function makeMenu()  
{  
menu.\_x=520;  
menu.\_y=-420;  
clearInterval(delay);  
var item = sub\_menu.createEmptyMovieClip(“pic”+q, q);  
item.loadMovie(pictArray[p]);  
var temp = \_parent.createEmptyMovieClip(“tmp”, 9999+q);  
temp.onEnterFrame = function()  
{  
var tot = item.getBytesTotal();  
var loa = item.getBytesLoaded();  
var per = Math.round(((loa/tot)_100)/(pictArray.length_2));  
loadBar.\_yscale = loadper+per;  
if (tot == loa && tot\>4)  
{  
item.id = p;  
loadper += per;  
if (q\>0) { item.\_y = sub\_menu[“pic”+(q-1)].\_y+sub\_menu[“pic”+(q-1)].\_width; }  
else { item.\_y = 0;}

```
        containerMC.loadPic(0);
        
        item.onRelease = function() 
         {
            containerMC.loadPic(this.id);
            var picID = this.id;
            setTimeout(5000);
         };
        nextItem();
        delete this.onEnterFrame;
    }
};

```

}

var amount = pictArray.length-1;  
function nextItem() {  
if (q\<((pictArray.length)-1)) {  
q++;  
if (p\<(pictArray.length-1)) {  
p++;  
makeMenu();  
} else {  
p = 0;  
makeMenu();  
}  
activateMenu();  
}  
}
