Hey guys:
I don’t know where to begin with words, so I’ll just start out with a picture:
01.gif shows my layout for my 3-image gallery. Flash loads a complete list of photos from a php file (which works) and 3 images at a time would be selected, resized, and placed into one of the image boxes. All of the pictures do in fact load like they should, but the problem is the resizing.
02.gif shows what goes wrong. The first and last images remain their original (huge) size. For some reason, only the 2nd picture is resized properly when all 3 image boxes are enabled, and the first picture is resized properly when the third image box is enabled (if that makes sense).
It sounds like a timing issue, but i honestly am clueless. Any suggestions would be greatly appreciated!
-Matt
—source
//--- define the current gallery page
pageNum = 1;
//--- use PHP to load and calculate total number of pages
totalPages = Math.ceil(totalPics / 3);
back_btn.enabled = false;
forward_btn.onRelease = function () {
pageNum = pageNum+1;
container1.loadPic(0 + ((pageNum-1) * 3));
container2.loadPic(1 + ((pageNum-1) * 3));
container3.loadPic(2 + ((pageNum-1) * 3));
back_btn.enabled = true;
if (pageNum == totalPages) {
forward_btn.enabled = false;
}
}
back_btn.onRelease = function () {
pageNum = pageNum-1;
container1.loadPic(0 + ((pageNum-1) * 3));
container2.loadPic(1 + ((pageNum-1) * 3));
container3.loadPic(2 + ((pageNum-1) * 3));
forward_btn.enabled = true;
if (pageNum == 1) {
back_btn.enabled = false;
}
}
//--- load totalPics from PHP file
countMe = new LoadVars ()
countMe.load("loadpics.php?dummy="+Math.random())
countMe.onLoad = function (true) {
if (true) { totalPics = this.cnt; }
}
//--- load pic locations from XML file
var pArray = new Array();
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++) {
pArray.push(gallery.childNodes*.attributes.src);
}
container1.loadPic(0 + ((pageNum-1) * 3));
container2.loadPic(1 + ((pageNum-1) * 3));
container3.loadPic(2 + ((pageNum-1) * 3));
}
}
gallery_xml.load("photos.xml");
//--- load pic into Flash
MovieClip.prototype.loadPic = function(pic) {
this.loadMovie(pArray[pic]);
this._parent.onEnterFrame = function() {
var num = pic - (3 * (pageNum - 1));
var frame = this["container"+num];
var t = frame.getBytesTotal();
var l = frame.getBytesLoaded();
per = Math.round((l/t) * 100);
if (l == t && frame._width>0 && frame._height>0) {
while (frame._width>150 || frame._height>150) {
frame._width = frame._width * 0.9;
frame._height = frame._height * 0.9;
} delete this.onEnterframe;
}
};
};