Es gibt unschöne Probleme in dieser eigentlich tollen Gallery die ich nicht zu lösen vermag:
1. Wieso wird jedes Bild immer neu geladen: Macht ja keinen Sinn bereits geladene Bilder noch einmal zu laden? Dennoch wird immer wieder von neuem geladen...? Wie kann ich das beheben? Ich möchte ja nicht jedes Bild der Thumbs einzeln, sondern alle mal laden.
2. An welcher Stelle macht es Sinn einen Preolader einzubauen: Ich würde gerne die kleinen Previews und die grossen Pics VOR dem anzeigen mit einem Balken oder einer Prozentanzeige preloaden und dann einfaden...weil so geht das ja nicht wirklich. DAS PROBLEM: Wo soll das am besten geschehen, damit es am effizientesten und schönsten geht ohne bastelei?
Danke Forumboysandmädels
Gruss der Syra
Zitat:
var tnNr;
spacing = 10;
container._alpha = 0;
var curLength;
MovieClip.prototype.loadPic = function(pic, id) {
info.text = "";
this._alpha = 0;
this.loadMovie(pic);
temp = this._parent.createEmptyMovieClip("temp2", 998);
temp.onEnterFrame = function() {
var t = container.getBytesTotal(), l = container.getBytesLoaded();
if (Math.round(l/t) == 1 && container._width != 0 && container._height != 0) {
var w = container._width+spacing, h = container._height+spacing;
border.resizeMe(w, h, id);
delete this.onEnterFrame;
}
};
};
MovieClip.prototype.resizeMe = function(w, h, id) {
var speed = 3;
container._alpha = 0;
this.onEnterFrame = function() {
this._width += (w-this._width)/speed;
this._height += (h-this._height)/speed;
if (Math.abs(this._width-w)<1 && Math.abs(this._height-h)<1) {
this._width = w;
this._height = h;
container._x = this._x-this._width/2+spacing/2;
container._y = this._y-this._height/2+spacing/2;
info._y = Math.round(this._y+this._height/2+spacing/2);
container._alpha += 5;
if (container._alpha>90) {
info.text = id;
container._alpha = 100;
delete this.onEnterFrame;
}
}
};
};
var galLength;
my_xml = new XML();
my_obj = new Object();
my_xml.ignoreWhite = true;
my_xml.onLoad = function(loaded) {
if (loaded) {
var galleries = this.firstChild.childNodes;
galLength = galleries.length;
for (var i = 0; i<galLength; i++) {
my_obj[i] = new Object();
my_obj[i].nodes = galleries[i].childNodes;
var gal_btn = nav_gal.attachMovie("gal_btn", "gal_btn"+i, i);
gal_btn._y = i*20;
gal_btn.label.text = galleries[i].attributes.name;
gal_btn.label.autoSize = true;
gal_btn.bg._width = gal_btn.label._width;
gal_btn.id = i;
gal_btn.onRelease = function() {
galleryChoice(this.id);
disButtons(this.id);
};
}
}
galleryChoice(0);
disButtons(0);
};
my_xml.load("gallery.xml");
function galleryChoice(q) {
tArray = [];
pArray = [];
iArray = [];
for (var j = 0; j<curLength; j++) {
this.th_nav["thmb"+j].removeMovieClip();
}
gallery = my_obj[q].nodes;
curLength = gallery.length;
for (var i = 0; i<gallery.length; i++) {
pArray.push(gallery[i].attributes.source);
tArray.push(gallery[i].attributes.thumb);
iArray.push(gallery[i].attributes.title);
}
delay = setInterval(makeButtons, 50);
}
function makeButtons() {
tnNr = 0;
clearInterval(delay);
for (var i = 0; i<tArray.length; i++) {
var thb = th_nav.thmb.duplicateMovieClip("thmb"+i, 1000+i);
thb.id = i;
thb._x = i%3*50;
thb._y = Math.floor(i/3)*50;
}
loadButtons();
}
function loadButtons() {
var tbox = th_nav["thmb"+tnNr].box;
tbox.loadMovie(tArray[tnNr]);
temp = this.createEmptyMovieClip("tmp"+tnNr, 999);
temp.onEnterFrame = function() {
bt = tbox.getBytesTotal();
bl = tbox.getBytesLoaded();
if (bt == bl && bt>4) {
nextButton();
delete this.onEnterFrame;
}
};
}
function nextButton() {
if (tnNr<tArray.length-1) {
tnNr++;
loadButtons();
} else {
activateButtons();
}
}
function activateButtons() {
mainButtons();
for (var i = 0; i<pArray.length; i++) {
var but = th_nav["thmb"+i];
but.id = i;
but.onRelease = function() {
container.loadPic(pArray[this.id], iArray[this.id]);
disButtons2(this.id);
};
}
container.loadPic(pArray[0], iArray[0]);
disButtons2(0);
}
function disButtons2(d) {
for (var i = 0; i<tArray.length; i++) {
if (i != d) {
this.th_nav["thmb"+i].enabled = 1;
this.th_nav["thmb"+i].box._alpha = 100;
} else {
this.th_nav["thmb"+i].enabled = 0;
this.th_nav["thmb"+i].box._alpha = 50;
}
}
}
function disButtons(d) {
for (var i = 0; i<galLength; i++) {
var but = nav_gal["gal_btn"+i];
if (i != d) {
but.enabled = 1;
but.gotoAndStop(1);
} else {
but.enabled = 0;
but.gotoAndStop(2);
}
}
} |