Ext Jpgs with loading bars - clean up actionscript + fade up/down
Hello
I've got a gallery i'm making in flash and need some help smoothing out the appearance of the loading process and also most probably the actionscript.
So the idea is a gallery with X number of pages with up to 2 images each page and the option of 3 different placements. See here for an example (only first 3 pages).
What i've done is make a 40 page template and added 3 empty movie clips and loading bars with the following actionscript:
Code:
emptyA.loadMovie("01a.jpg");
loadingBarA._xscale = 1;
loadingBarA.onEnterFrame = function() {
kBytesLoaded = this._parent.emptyA.getBytesLoaded() / 1024;
kBytesTotal = this._parent.emptyA.getBytesTotal() / 1024;
percentage = Math.round(kBytesLoaded / kBytesTotal * 100);
this._xscale = percentage;
if (percentage == 99) {
delete this.onEnterFrame;
}
}
emptyB.loadMovie("01b.jpg");
loadingBarB._xscale = 1;
loadingBarB.onEnterFrame = function() {
kBytesLoaded = this._parent.emptyB.getBytesLoaded() / 1024;
kBytesTotal = this._parent.emptyB.getBytesTotal() / 1024;
percentage = Math.round(kBytesLoaded / kBytesTotal * 100);
this._xscale = percentage;
if (percentage == 99) {
delete this.onEnterFrame;
}
}
emptyC.loadMovie("01c.jpg");
loadingBarC._xscale = 1;
loadingBarC.onEnterFrame = function() {
kBytesLoaded = this._parent.emptyC.getBytesLoaded() / 1024;
kBytesTotal = this._parent.emptyC.getBytesTotal() / 1024;
percentage = Math.round(kBytesLoaded / kBytesTotal * 100);
this._xscale = percentage;
if (percentage == 99) {
delete this.onEnterFrame;
}
}
stop();
The idea is that the client can upload an image and position it by defining the page number and position in it's name eg. 01c.jpg will be 01 (page01) c (far right position).
I found the actionscript on a forum website and it seems to work ok but it's really jerky and no doubt incredibly longwinded. Ideally i'd like it to load evenly each time with a little fade up and down like this website.
It would be cool to have each of the 3 loading bars work but if needs be i could always use just one.
Also is there a way of assigning a bit of script? e.g. if image is not found, display blank image (1x1 pix white jpg), this would stop the missing image errors each time you click to the page. Or even better, no load if image not found, thus stopping random loading bar loads then no image.
Massive thanks to anyone who can put me on the right track for this.
Here's the Fla file if that's any help. Please let me know if you need any other info.
Cheers
Gordon