# Preloader in photo gallery ..?

**URL:** <https://forum.kirupa.com/t/preloader-in-photo-gallery/83554>\
**Category:** Uncategorized\
**Created:** [March 20, 2005, 2:29am UTC](https://forum.kirupa.com/t/preloader-in-photo-gallery/83554 "2005-03-20T02:29:40Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![miras](https://avatars.discourse-cdn.com/v4/letter/m/e36b37/32.png) [@miras](https://forum.kirupa.com/u/miras)\
**Post date:** [March 20, 2005, 2:29am UTC](https://forum.kirupa.com/t/preloader-in-photo-gallery/83554/1 "2005-03-20T02:29:40Z")

</div>

hi, does anybody know how to throw in some kind of simple preloader for each photo within this action sript from resize photo gallery ?

* * *

spacing = 0;  
containerMC.\_alpha = 0;  
var pArray = new Array();  
var tArray = new Array();  
MovieClip.prototype.loadPic = function(pic) {  
containerMC.\_alpha = 0;  
cur = pic;  
this.loadMovie(pArray[pic]);  
this.\_parent.onEnterFrame = function() {  
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, pic);  
bar.\_visible = 0;  
picinfo.info.text = tArray[pic];  
delete this.\_parent.onEnterFrame;  
} else {  
bar.\_width = per;  
// gives the bar a max width 100. För att få 250 px t.ex: bar.\_width = per_2.5;  
picinfo.info.text = per+" % ";  
}  
};  
};  
MovieClip.prototype.resizeMe = function(w, h, pic) {  
containerMC.\_alpha = 0;  
var speed = 3;  
this.onEnterFrame = function() {  
this.\_width += (w-this.\_width)/speed;  
this.\_height += (h-this.\_height)/speed;  
// nav.\_x = Math.round(this.\_x-this.\_width/2);  
// nav.\_y = Math.round(this.\_y+this.\_height/2+spacing/2);  
// prevb.\_x = nav.\_x-5;  
// nextb.\_x = nav.\_x+this.\_width+5;  
// nextb.\_y = prevb.\_y=this.\_y-this.\_height/2;  
picinfo.\_y = nextb.\_y-5;  
picinfo.\_x = border.\_x-picinfo.\_width/2;  
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-spacing/2);  
containerMC.\_alpha += 10;  
if (containerMC.\_alpha\>100) {  
containerMC.\_alpha = 100;  
delete this.onEnterFrame;  
}  
}  
};  
};  
var gallery\_xml = new XML();  
gallery\_xml.ignoreWhite = true;  
gallery\_xml.onLoad = function(success) {  
if (success) {  
var gallery = this.firstChild;  
for (var i = 0; i\<gallery.childNodes.length; i++) {  
tArray.push(gallery.childNodes\*.attributes.title);  
pArray.push(gallery.childNodes\*.attributes.source);  
}  
//loading first picture  
containerMC.loadPic(0);  
} else {  
title\_txt.text = “Error!”;  
}  
};  
gallery\_xml.load(“gallery.xml”);  
prevb.onRelease = function() {  
if (cur == 0) {  
containerMC.loadPic(pArray.length-1);  
} else {  
containerMC.loadPic(cur-1);  
}  
};  
nextb.onRelease = function() {  
if (cur == pArray.length-1) {  
containerMC.loadPic(0);  
} else {  
containerMC.loadPic(cur+1);  
}  
};

gallery\_xml.load(“gallery.xml”);  
border.onRelease = function() {  
if (cur == pArray.length-1) {  
containerMC.loadPic(0);  
} else {  
containerMC.loadPic(cur+1);  
}  
};
