Ho tolto un pò di cose dallo script per renderlo più leggibile eccolo
var imglist = new XML();
var borderspace=2;
loadText.text="";
loadBar._width ="";
imglist.ignoreWhite = true;
loadText.text="loading xml";
imglist.onLoad = function() {
createGalerie();
};
imglist.load("eyelash_xml_render.php");
//Création de la galerie
function createGalerie() {
//liste des images
var photo_dir = imglist.firstChild.attributes.images;
var thumb_dir = imglist.firstChild.attributes.thumbnails;
loadText.text="loading images from " + photo_dir;
var eyelash_nodes = imglist.firstChild.childNodes;
for (var i = 0; i<eyelash_nodes.length; i++) {
var image_name = eyelash_nodes[i].attributes.name;
//create a clip / move to size / position
var img = this.createEmptyMovieClip("img"+i, i);
var nb_columns = 3;
img._x = (i%nb_columns)*60+4;
img._y = Math.floor(i/nb_columns)*60+10;
//load thumbnail
var view = img.createEmptyMovieClip("view", 0);
view.loadMovie(thumb_dir+image_name);
//On enregistre les infos
img.image_name = photo_dir+image_name;
img.width = eyelash_nodes[i].attributes.width;
img.height = eyelash_nodes[i].attributes.height;
//display image on click
img.onRelease = function() {
//popup(this.nom, this.width, this.height);
imageLoad(this.image_name);
};
img.onRollOver = function() {
gFadeOut(this,10, 20);};
img.onRollOut = function() {gFadeIn(this, 10, 90)};
}
var main = this.createEmptyMovieClip("main", i+1);
main._x=200;
main._y=10;
imageLoad(photo_dir + eyelash_nodes[0].attributes.name);
}
function imageLoad(filename)
{
timeout=250;
main._alpha=0;
main.loadMovie(filename);
img_loading_ID=setInterval(LoadingStatus,250);
}
function LoadingStatus(){
bl=main.getBytesLoaded()
bt=main.getBytesTotal()
if (bt!=0) {per=Math.round((bl/bt)*100); }
else {per=0;}
loadBar._width = per ;
loadText.text = "loading..." + Math.round(bl / 1024) + " Kb ... " + per + "%";
if(per>=100){
clearInterval(img_loading_ID);
fadeOut = setInterval(fadeOut,0.5);
fadeInt = setInterval(fadeIn,1);
loadText.text = "image loaded : " + Math.round(bl / 1024) + " kb.";
mainBorder();
}
}
function fadeIn(){
main._alpha+= 1;
if(main._alpha>99){
main._alpha = 100;clearInterval(fadeInt);}
}
function fadeOut(){
main._alpha-= 1;
if(main._alpha<1){
main._alpha = 0;clearInterval(fadeOut);}
}
gFadeOut = function (mc, step, target) {
mc.onEnterFrame = function() {
newAlpha = mc._alpha - step;
if (newAlpha <= target) {
newAlpha = target;
delete mc.onEnterFrame;
}
mc._alpha = newAlpha;
};
};
gFadeIn = function (mc, step, target) {
mc.onEnterFrame = function() {
newAlpha = mc._alpha + step;
if (newAlpha >= target) {
newAlpha = target;
delete mc.onEnterFrame;
}
mc._alpha = newAlpha;
};
};

Rispondi quotando