My portfolio is a combination of elements from Kirupa’s gallery and my own.
The portfolio works fine but the loader just doesn’t work correctly. It can be tested at http://www.visim.com/testgallery/portfolio.html
*) In Firefox the loadbar flashes once(which it shouldn’t do) and the dynamic text box displays a NaN% and then 100% so something isn’t being defined correctly. In IE 6.5 however there is no NaN% displayed, the preload bar flashes once and then works fine. I don’t know why there would be a difference between browsers.
Please take a look at the code below and let me know why the files being loaded into the picture container aren’t correctly preloading. It’s been a week of working on this endless portfolio and I just want it to be over.
Thanks
Neil
var filesize = picture.getBytesTotal();
var loaded = picture.getBytesLoaded();
function loadXML(success) {
if (success) {
xmlNode = this.firstChild;
image = [];
description = [];
sectitle = [];
thumbnails = [];
client = [];
project = [];
_global.total = xmlNode.childNodes.length;
for (i=0; i<total; i++) {
image* = xmlNode.childNodes*.childNodes[0].firstChild.nodeValue;
description* = xmlNode.childNodes*.childNodes[1].firstChild.nodeValue;
thumbnails* = xmlNode.childNodes*.childNodes[2].firstChild.nodeValue;
sectitle* = xmlNode.childNodes*.childNodes[3].firstChild.nodeValue;
client* = xmlNode.childNodes*.childNodes[4].firstChild.nodeValue;
project* = xmlNode.childNodes*.childNodes[5].firstChild.nodeValue;
thumbnailer(i);
}
firstImage();
} else {
trace("file not loaded!");
}
}
xmlData = new XML();
xmlData.ignoreWhite = true;
xmlData.onLoad = loadXML;
xmlData.load(_root.xmlDoc);
/////////Load First Image Function///////////////////////////////////////////////
function firstImage() {
if (loaded == filesize) {
preXML();
picture._alpha = 0;
picture.loadMovie(image[0], 1);
desc_txt.text = description[0];
title_txt.text = sectitle[0];
client_txt.text = client[0];
project_txt.text = project[0];
}
}
/////////Image Preloader Function//////////////////////////////////////////////////////
p = 0;
function preXML() {
preloader.preload_bar._alpha = 100;
preloader.preload_bar._visible = true;
this.onEnterFrame = function() {
filesize = picture.getBytesTotal();
loaded = picture.getBytesLoaded();
//preloader.preload_bar._visible = true;
myPercent = loaded/filesize;
myText = Math.round(myPercent*100)+"%";
if (loaded != filesize) {
preloader.preload_bar._width = 100*loaded/filesize;
} else {
if(preloader.preload_bar._alpha > 0){
preloader.preload_bar._alpha -= 10;
}else{
preloader.preload_bar._visible = false;
}
if (picture._alpha<100) {
picture._alpha += 10;
}
}
}
};
preXML();
//////////Load clicked thumbnail Image Function////////////////////////////////////////////////
function callImage() {
if (loaded == filesize) {
picture._alpha = 0;
picture.loadMovie(image[p], 1);
desc_txt.text = description[p];
//title_txt.text = sectitle[p];
client_txt.text = client[p];
project_txt.text = project[p];
}
}
//////////Enable All the Buttons//////////////////////////////////////////
function enableButtons() {
for (var cclip = 0; cclip<_global.total; cclip++) {
this["this.thumbnail_mc.th"+cclip].enabled = false;
enabled = false;
//_alpha = 20;
}
}
//////////Thumbnail maker///////////////////////////////
function thumbnailer(k) {
loaded_counter = 0;
total_thumbs = _global.total;
var container = thumbnail_mc.createEmptyMovieClip("th"+k, thumbnail_mc.getNextHighestDepth());
container._visible = false;
container._alpha = 0;
var image = container.createEmptyMovieClip("img", container.getNextHighestDepth());
tlistener = new Object();
tlistener.onLoadInit = function(target_mc) {
target_mc.pictureValue = k;
//make the initial thumbnail disabled and transparent
var initialBut = thumbnail_mc.th0.img;
thumbnail_mc.th0.img.enabled = false;
thumbnail_mc.th0.img._alpha = 50;
target_mc.onRelease = function() {
initialBut.enabled = true;
initialBut._alpha = 100;
oldBtn.enabled=true;
oldBtn._alpha=100;
p = this.pictureValue;
callImage();
preXML();
clearInterval(_root.container.picture.hold);
this._alpha = 50;
this.enabled = false;
oldBtn=this;
};
target_mc.onRollOver = function() {
this._alpha = 50;
_root.firstSound.start();
};
target_mc.onRollOut = function() {
this._alpha = 100;
};
loaded_counter++;
counting_txt = loaded_counter;
if (loaded_counter == total_thumbs) {
main_menu.boton1._visible = false;
main_menu.boton2._visible = false;
grid_maker_01();
}
};
image_mcl = new MovieClipLoader();
image_mcl.addListener(tlistener);
image_mcl.loadClip(thumbnails[k], "thumbnail_mc.th"+k+".img");
}