Preloader
Copy link to clipboard
Copied
Adobe Flash CS3
Action Script 1.0 & 2.0
Hello, Im just almost done with my site. Just put in a preloader in the 1st scene of my site, and this is the script I put in:
stop();
addEventListener(Event.ENTER_FRAME, loading);
function loading(e:Event):void{
var total_bytes:Number = this.stage.loaderInfo.bytesTotal;
var loaded_bytes:Number = this.stage.loaderInfo.bytesLoaded;
rectangle_clip.scaleX = loaded_bytes/total_bytes;
text_clip.text = Math.floor((loaded_bytes/total_bytes)*100)+="%";
if (total_bytes==loaded_bytes){
gotoAndPlay(2);
this.removeEventListener(Event.ENTER_FRAME, preload1);
}
}
Went to go test my site, this is the error message I got:
Why am I getting these error messages? Any help would be appreciated. Thanks
Copy link to clipboard
Copied
That's AS3 code, so if you're working in AS2, you should find yourself an AS2 preloader.
Copy link to clipboard
Copied
would this work?
bytes_loaded = Math.round(this.getBytesLoaded());
bytes_total = Math.round (this.getBytesTotal());
getPercent = bytes_loaded/bytes_total;
this.rectangle_clip._width = getPercent*200;
this.text_clip = Math.round(getPercent*100)+"%";
if (bytes_loaded == bytes_total){
gotoAndPlay(2);
}
I get no error message with this one, but when I went to go test it out and did "simulate download" I did not see the load bar move at all. And on top of that, I don't even see the percent number. is this good or bad? If bad, how can I fix it?
Copy link to clipboard
Copied
No that won't work, at least not in any way you might expect it to. You should search Google for an example of an AS2 preloader. That way, not only will you find code to help you, you will hopefully also get an explanation so that you can try to understand what the different parts do.
Copy link to clipboard
Copied
I'm pulling my frickin hair out trying to look for something, I tried this, and this example didnt work
http://the-dude.co.uk/tutorials/flash-as2-tutorials/advanced-flash-preloaders-as2/
Copy link to clipboard
Copied
is there any way to incorporate the scale action, and show the percent that the user has left using this tutorial?
Copy link to clipboard
Copied
I found some AS for the AS2 preloader that MIGHT work, BUT, I would like to incorporate the scale action for the load bar itself without having to make a tween action. So, my question is this:
Is there any way to incorporate this:
)else (
preLoader.Fill.scaleX = numberLoaded/bytesLoad;
preLoader.bytesPercent.text = Math.floor(numberLoaded/byteLoad*100) + "%";
Into this:
this.onEnterFrame = function(){
amount = this.getBytesLoaded() / this.getBytesTotal;
preLoader._width = Math.round(amount * 860.2);
if(amount == 1){
this.gotoAndStop(2);
}
}
And still have it work properly with no errors? Any help and advice would be appreciated. Thanks.
Copy link to clipboard
Copied
Then just incorporate it, try...
this.onEnterFrame = function(){
amount = this.getBytesLoaded() / this.getBytesTotal();
preLoader.Fill._xscale = amount;
preLoader.bytesPercent.text = Math.floor(amount*100) + "%";
if(amount == 1){
this.gotoAndStop(2);
}
}
Copy link to clipboard
Copied
whil Im still googling and youtubing all over the net for a possible answer myself, I know you guys are probably getting annoyed with me right about now, but ARGH, this is all frustrating, so I apologize. lol
and secondly, I did try that and all I got on the test page was a frozen load bar that did not show any kind of percentage whatsoever, did not scale from 0-100, it just sat there, full load and all and few seconds later my page popped up. Tried differnt download simulations and they all did the same thing. This is driving me nuts. lol, WHAT THE HELL?! lol
dammit.... I think I got it!
http://the-dude.co.uk/tutorials/flash-as2-tutorials/advanced-flash-preloaders-as2/
Copy link to clipboard
Copied
In case you don't check the forum for answers (you should) I changed the code slightly since scaleX is AS3... _xscale is AS1/2.
Copy link to clipboard
Copied
that link I sent was AWESOME!!!! My research paidoff!!!!! All thats left now is to button up a few odds and end, make all the buttons work and I should be good to go. Even tho I just answered my own question and reserched it on my own, because you guys are so helpful and cool about everything, I'll give you guys the star for it anyways. Thanks.
Copy link to clipboard
Copied
You're welcome

