Hi all,
I'm making a flash photo gallery
Everything is working fine except two points:

- If I'm on the 1st picture and I press back instead of next,
the xml text will be 'undefined' cause it's looking a picture who doesn't exist.
The gallery should stay on picture n°1 and not go to picture n°0
Same problem for the last picture.
I'm kinda newbie in AS and I can't find a solution to automatically stop the gallery,
or to make it as a loop.
Can anybody help me?

- I found a usefull trick, I set the 1st picture to be visible during the loading
so all the pictures load in the background without the visitor notice it
so he can already browse the gallery.
The problem is that the picture n°1 always stays visible at the back,
when I try to make alpha transitions between each picture, the picture n°1 always appear on the back. Is there's a way to delete it at the moment the visitor begins to browse the gallery?

Thanks alot to take a look at the code below
h.


function loadXML(loaded) {
        if (loaded) {
                xmlNode = this.firstChild;
                image = [];
                description = [];
                total = xmlNode.childNodes.length;
                for (i=0; i<total; i++) {
                        image[i] = 
xmlNode.childNodes[i].childNodes[0].firstChild.nodeValue;
description[i] = xmlNode.childNodes[i].childNodes[1].firstChild.nodeValue;
                }
                id = setInterval(preloadPic, 100);
        } else {
                content = "file not loaded!";
        }
}
xmlData = new XML();
xmlData.ignoreWhite = true;
xmlData.onLoad = loadXML;
xmlData.load("images05.xml");
var loadTot = 0;
var k = 0;
// ///////////////////////////////////
function preloadPic() {
        clearInterval(id);
        var con = picture.duplicateMovieClip("con"+k, 9984+k);
        con.loadMovie(image[k]);
        var temp = _root.createEmptyMovieClip("temp"+k, 99+k);
        temp.onEnterFrame = function() {
                var total = con.getBytesTotal();
                var loaded = con.getBytesLoaded();
                percent = Math.round((loaded/total*100)/image.length);
                preloader.preload_bar._xscale = loadTot+percent;
                info.text = "Loading picture "+k+" of "+image.length+" total";
                if (loaded == total && total>4) {
                        con._visible = 0;
                        con0._visible = 1;
                        nextPic();
                        loadTot += percent;
                        delete this.onEnterFrame;
                        }
        };
}
function nextPic() {
        if (k<image.length-1) {
                k++;
                preloadPic();
        } else {
                firstImage();
                trace("hit");
        }
}
listen = new Object();
listen.onKeyDown = function() {
        if (Key.getCode() == Key.LEFT) {
                prevImage();
        } else if (Key.getCode() == Key.RIGHT) {
                nextImage();
        }
};
Key.addListener(listen);
previous_btn.onRelease = function() {
        prevImage();
};
next_btn.onRelease = function() {
        nextImage();
};


// ///////////////////////////////////
var p = 0;
var current;
MovieClip.prototype.fadeIn = function() {
        if (this._alpha<100) {
                current._alpha -= 100;
                this._alpha += 100;
        } else {
                current._visible = 0;
                delete this.onEnterFrame;
        }
};
function nextImage() {
        current = this["con"+p];
        p++;
        var picture = this["con"+p];
        picture._visible = 1;
        picture._alpha = 0;
        picture.onEnterFrame = fadeIn;
        desc_txt.text = description[p];
        picture_num();
                        if (p>11) {
        current = this["con"+p];
        p--;
        var picture = this["con"+p];
        }
}
function prevImage() {
        current = this["con"+p];
        p--;
        var picture = this["con"+p];
        picture._visible = 1;
        picture._alpha = 0;
        picture.onEnterFrame = fadeIn;
        desc_txt.text = description[p];
        picture_num();
                if (p<-0) {
        current = this["con"+p];
        p++;
        var picture = this["con"+p];
        }
}

function firstImage() {
        con0._visible = 1;
        con0._alpha = 0;
        con0.onEnterFrame = fadeIn;
        desc_txt.text = description[0];
        picture_num();
}

function picture_num() {
        current_pos = p+1;
        pos_txt.text = current_pos+" / "+total;
}

_______________________________________________
Flashcoders@chattyfig.figleaf.com
To change your subscription options or search the archive:
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders

Brought to you by Fig Leaf Software
Premier Authorized Adobe Consulting and Training
http://www.figleaf.com
http://training.figleaf.com

Reply via email to