I need to dynamically preload my thumbs ,but i think its going to be kind of tricky since I’m using XML for all my images…and I don’t know how to tweak the code even though there’s comments for everything in the AS.
Senocular has a folder for his .jpgs.
I have the gallery.xml & folder named pics w/ all my thumbs & jpgs in there…so what do i need to change?:puzzle:
[COLOR=darkred]THANK u!!![/COLOR]
[COLOR=magenta]CODE 4 THE PRELOADING THUMBS[/COLOR]
var baseurl = _url.substr(0,_url.lastIndexOf("/")+1);
h_spacing = 130; // horizontal spacing
v_spacing = 110; // vertical spacing
h_count = 4; // number of thumbnails horizontally
v_count = 3; // number of thumbnails vertically
h_pos = 20; // starting horizontal position of grid
v_pos = 20; // starting vertical position of grid
count = 0; // counts clips added in the grid when created and for loading
thumb_clips = new Array(); // movieclips to contain thumbs
thumb_graphics = new Array(); // urls of the jpgs to be loaded as thumbs
for (i=1; i<=12; i++) thumb_graphics.push(baseurl + "gallery/thumb"+i+".jpg"); // populate thumb_graphics with jpg urls
// CreateThumbContainers creates the grid of thumb_clips
function CreateThumbContainers(){
var x, y, initObj, curr;
for (y=0; y<v_count; y++){
for (x=0; x<h_count; x++){
count++;
initObj = {_x: h_pos + x*h_spacing, _y: v_pos + y*v_spacing};
curr = this.attachMovie("thumb_container", "tc"+count+"_mc", count, initObj);
curr.progress_mc._xscale = 0;
thumb_clips.push(curr);
}
}
}
// ThumbLoadingEnterFrame is the onEnterFrame handler to be used
// for preloading each thumbnail and driving the progress bar
function ThumbLoadingEnterFrame(){
var lod = this.loader_mc.getBytesLoaded();
var tot = this.loader_mc.getBytesTotal();
if (lod && tot){
var percent_loaded = lod/tot;
this.progress_mc._xscale = 100 * percent_loaded;
if (percent_loaded == 1){
LoadNextThumb();
delete this.onEnterFrame;
}
}
}
// LoadNextThumb, called by ThumbLoadingEnterFrame, loads the next
// thumbnail in the thumb_clips list when the current one is complete
function LoadNextThumb(){
if (count >= thumb_graphics.length) return false;
var imgURL = thumb_graphics[count];
thumb_clips[count].loader_mc.loadMovie(imgURL);
thumb_clips[count].onEnterFrame = ThumbLoadingEnterFrame;
count++;
}
// create grid
CreateThumbContainers();
// reset count
count = 0;
// initiate loading of thumbs
LoadNextThumb();
// LoadNextThumb(); // <- using 2 LoadNextThumb() calls will load 2 at a time
[COLOR=darkorchid]CODE 4 MY Gallery[/COLOR]
dest1 = dest2 = dest3 = dest4 = dest5 = gal1_btn._y;
var tnNr;
spacing = 10;
var curLength;
easeAmount = 3;
MovieClip.prototype.loadPic = function(pic, id) {
delete burn();
info.text = "";
this.loadMovie(pic);
temp = this._parent.createEmptyMovieClip("temp2", 998);
temp.onEnterFrame = function() {
var t = container.getBytesTotal(), l = container.getBytesLoaded();
bar._width = ((l/t)*100);
var percentage = (Math.round(l/t)*100)+"%";
if ((l/t) == 1 && container._width != 0 && container._height != 0) {
var w = container._width+spacing, h = container._height+spacing;
bar._visible = false;
container._visible = 0;
border.resizeMe(w, h, id);
delete this.onEnterFrame;
}
};
};
MovieClip.prototype.resizeMe = function(w, h, id) {
var speed = 2;
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);
if (this._width>=w) {
burn(255);
container._visible = 1;
info.text = id;
delete this.onEnterFrame;
}
}
};
};
burn = function(ori) {
this.ori=ori;
this.jj = new Color(container);
this.col = this.jj.getTransform();
this.col.rb = this.col.gb = this.col.bb = this.ori;
this.jj.setTransform(this.col);
this.val = 0;
this.col.aa = 100;
this.onEnterFrame = function() {
if (this.val!=this.col.bb) {
this.col.rb = this.col.gb=this.col.bb += (this.val-this.col.bb)/20;
this.jj.setTransform(this.col);
}else {
delete this.onEnterFrame;
}
};
};
function galleryChoice(q) {
pArray = new Array();
tArray = new Array();
iArray = new Array();
my_xml = new XML();
container._alpha = 0;
for (var j = 0; j<curLength; j++) {
this.scroll.th_nav["thmb"+j].removeMovieClip();
}
my_xml.ignoreWhite = true;
my_xml.onLoad = function(loaded) {
if (loaded) {
gallery = this.firstChild.childNodes[q];
curLength = gallery.childNodes.length;
for (var i = 0; i<gallery.childNodes.length; i++) {
pArray.push(gallery.childNodes*.attributes.source);
tArray.push(gallery.childNodes*.attributes.thumb);
iArray.push(gallery.childNodes*.attributes.title);
}
}
delay = setInterval(makeButtons, 50);
};
my_xml.load("gallery.xml");
}
function makeButtons() {
tnNr = 0;
clearInterval(delay);
for (var i = 0; i<tArray.length; i++) {
var thb = scroll.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 = scroll.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 = scroll.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);
}
butArray = new Array();
butArray = ["gal1_btn", "gal2_btn", "gal3_btn", "gal4_btn", "gal5_btn", "gal6_btn", "gal7_btn"];
function mainButtons() {
for (var i = 0; i<butArray.length; i++) {
this[butArray*].id = i;
this[butArray*].onRelease = function() {
galleryChoice(this.id);
disButtons(this.id);
}
}
}
function disButtons2(d) {
for (var i = 0; i<tArray.length; i++) {
if (i != d) {
this.scroll.th_nav["thmb"+i].enabled = 1;
this.scroll.th_nav["thmb"+i].box._alpha = 100;
} else {
this.scroll.th_nav["thmb"+i].enabled = 0;
this.scroll.th_nav["thmb"+i].box._alpha = 50;
}
}
}
function disButtons(d) {
for (var i = 0; i<butArray.length; i++) {
if (i != d) {
this[butArray*].enabled = 1;
this[butArray*]._alpha = 100;
} else {
this[butArray*].enabled = 0;
this[butArray*]._alpha = 50;
}
}
}
disButtons(0);
galleryChoice(0);