PDA

View Full Version : my thumbnail preloader woes...



mindfriction
January 29th, 2004, 04:52 AM
Hi im having huge diemmas.

I have a script for loading pcitures into thumbnails which works perfect locally, but over the net it is very chunky and slow. Anyway to cut a long story short ive tried to implement a preloader, which is quiet simply is dynamically created textfield attached to each thumb with download progress displayed. Its almost like I need a preloader for the preloader though, lol. It seems the textfield only gets created at the same time the thumbnail pic appears?

Here's a snippet of my code..







............
..............
curr_thumb.loadMovie(curr_thumb.variables);
preload(curr_thumb);
}
//_root.scrollpane_cmp.setScrollContent(curr_gallery );
};
// var count = 0;
preload = function (curr_thumb) {

var curr_dummy = curr_thumb._parent.createEmptyMovieClip("dummy"+curr_thumb.index+"_mc", curr_thumb.depth+1);
curr_dummy.createTextField("label"+curr_thumb.index+"_txt", 0,curr_thumb._x,curr_thumb._y,600,600);
curr_dummy["label"+curr_thumb.index+"_txt"].text = curr_thumb.index;
//curr_thumb.label.text="hello";
trace("curr_thumb parent: " + curr_thumb._parent);
trace("parent's depth: " +depth);
trace("preload "+container);
curr_dummy.onEnterFrame = function() {
var t = curr_thumb.getBytesTotal(), l = curr_thumb.getBytesLoaded();
if (t && !isNaN(t)) {
var percent = Math.round(l*100/t);
if (l == t) {
trace("loading complete");
curr_thumb._width = 174;
curr_thumb._height = 112;
curr_thumb.onRollOver = curr_thumb.onDragOver=selectThumb;
curr_thumb.onRollOut = curr_thumb.onDragOut=deselectThumb;
curr_thumb.onRelease = activateThumb;
this.removeMovieClip();
} else {
trace("loading "+percent+" %");
curr_dummy["label"+curr_thumb.index+"_txt"].text = percent+" %";

}
}
};

mindfriction
January 29th, 2004, 10:39 PM
current version, still problems :(, ive tried to run a trace statement to show the percentage loading of each thumb



generateThumbs = function (container, name, x, y, depth, node_xml) {
var curr_node;
var curr_thumb;
var total_thumbs = node_xml.childNodes.length;
var curr_gallery = container.createEmptyMovieClip(name, depth);
bottom += 112*total_thumbs;
for (var i = 0; i<total_thumbs; i++) {
trace("loop "+i);
thumb_depth = i*5;
curr_thumb = curr_gallery.createEmptyMovieClip("thumb"+i+"_mc", thumb_depth);
curr_thumb.depth = thumb_depth;
curr_thumb._x = x;
curr_thumb._y = y+(i*112);
curr_thumb.trackAsMenu = true;
curr_node = node_xml.childNodes[i];
curr_thumb.index = i;
curr_thumb.action = curr_node.attributes.action;
curr_thumb.variables = curr_node.attributes.variables;
curr_thumb.name = curr_thumb.createTextField("label"+i+"_txt", curr_thumb.depth+1, 0, 0, 100, 20);
curr_thumb.name.text = curr_node.attributes.name;
curr_thumb.loadMovie(curr_thumb.variables);
preload(curr_thumb);
}
_root.scrollpane_cmp.setScrollContent(curr_gallery );
};
// var count = 0;
preload = function (curr_thumb) {
var curr_dummy = curr_thumb._parent.createEmptyMovieClip("dummy"+curr_thumb.index+"_mc", curr_thumb.depth+2);
trace(curr_dummy);
trace("preload "+container);
curr_dummy.onEnterFrame = function() {
var t = curr_thumb.getBytesTotal(), l = curr_thumb.getBytesLoaded();
trace(curr_thumb.getBytesLoaded());
if (t && !isNaN(t)) {
var percent = Math.round(l*100/t);
if (l == t) {
curr_thumb.initThumb();
this.removeMovieClip();
} else {
trace("loading "+curr_thumb+" "+percent+" %");
}
}
};
};

lauraloha
March 15th, 2004, 10:16 PM
I created this one let me know how it loads, and if you like it I'll send you the code

http://fashionstylemag.com/Ricky/images/