-
jpeg percentage loader (not preloader)
The script below loads a random jpeg dynamically onto my site..
picTotal = 18;
// adjust per total pics, img1.jpg,...,imgN.jpg, where N=picTotal
name1 = "img"+Math.ceil(Math.random()*picTotal)+".jpg" ;
loadMovie(name1, _root.BG);
// use loadMovie when loading into a target movielcip
preloadI = setInterval(preloadF, 10);
function preloadF() {
if (_root.BG.getBytesLoaded()>=_root.BG.getBytesTotal ()) {
// you must reference the target level or clip.
_root.BG._x = 0;
// try 0, 0 first. see if that lines up your background pics.
_root.BG._y = 0;
clearInterval(preloadI);
}
}
how could i adapt it to show percentage of the jpeg loaded? as some jpegs take long to load and it would be nice for the viewer to see what happeneing (the jpegs are small and making them smaller would be difficult.
-
Senior Member
Add a dynamic textfield with variable name precent..and try this.....
tb = math.round(_root.getBytesTotal()/1024);
lb = math.round(_root.getBytesLoaded()/1024);
percent = math.round((lb/tb)*100);
picTotal = 18;
// adjust per total pics, img1.jpg,...,imgN.jpg, where N=picTotal
name1 = "img"+Math.ceil(Math.random()*picTotal)+".jpg" ;
loadMovie(name1, _root.BG);
// use loadMovie when loading into a target movielcip
preloadI = setInterval(preloadF, 10);
function preloadF() {
if (lb>=tb && tb>1) {
// you must reference the target level or clip.
_root.BG._x = 0;
// try 0, 0 first. see if that lines up your background pics.
_root.BG._y = 0;
clearInterval(preloadI);
}
}
-
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|