Copy link to clipboard
Copied
Hi All..
I have a preloader that I created based on a tutorial.. it doesn't give me any errors, however, when I test it online - the bar doesn't show progress, but just sits at 99% and with the bar fully loaded, but the animation doesn't start.. any ideas? Thank you ahead of time! Here's the code:
stop();
this.addEventListener(Event.ENTER_FRAME, loading);
function loading(e:Event):void {
var total:Number = this.stage.loaderInfo.bytesTotal;
var loaded:Number = this.stage.loaderInfo.bytesLoaded;
bar_mc.scaleX = loaded/total;
loader_txt.text = Math.floor((loaded/total)*100)+ "%";
if (total == loaded) {
play();
this.removeEventListener(Event.ENTER_FRAME, loading);
}
}
Copy link to clipboard
Copied
the problem's not in that code. you're doing something else to cause the problem.
Copy link to clipboard
Copied
Define
total variable and try one more time
Copy link to clipboard
Copied
it is defined.
Copy link to clipboard
Copied
Yes...it is..
I'm trying to go with a totally different approach - with external Preloader...From what I've been readingthat seems the cleanest way to go...
Copy link to clipboard
Copied
this code worked:)
stop();
var loaded:Number;
var percent:Number;
fm_bar.addEventListener(Event.ENTER_FRAME, load_progress);
function load_progress(e:Event):void
{
loaded = stage.loaderInfo.bytesLoaded / stage.loaderInfo.bytesTotal;
percent = Math.round(loaded * 100);
fm_bar.scaleX = loaded;
loader_info.text = "loading..." + percent + "%";
if(percent == 100)
{
fm_bar.removeEventListener(Event.ENTER_FRAME, load_progress);
gotoAndPlay("begin");
}
}
Copy link to clipboard
Copied
Aggghhh - this code works fine in Firefox - but in Safari and IE it doesn't load all the way (jut preloader screen) and gives the following error:
Infinity%
Any ideas would be super appreciated - thanks a bunch ahead of time...
Copy link to clipboard
Copied
the code you last showed wouldn't cause that output. you're doing something else to cause that problem.
Copy link to clipboard
Copied
Thanks Kglad... I'm not sure what it could possibly be..
My set up is as follows:
Frame 1:
The pre-loader code, pre-loader mc
Frame 2:
"begin" label, evertying else..(timeline animations etc)
So, frame 1 only has the loader and the code and the rest of the animation starts on frame 2..I also have some code inside the movie clips on timeline animation.. could that be the problem? Should ALL the code be on first frame and target deep?
Copy link to clipboard
Copied
No - other code doesn't affect it... I treid removing it..
Copy link to clipboard
Copied
make sure you're using the html page published by flash.
Copy link to clipboard
Copied
Thanks Kglad - I just tried that - it does the same thing...
It's fine in Firefox - and it gives an error in Safari (I don't have IE here on my Mac - but when I give it to IT to test - it seems both IE and Chrome act similar to Safari) - so weird...
I modified to code to the following:
stop();
var loaded_bytes:Number;
var total_bytes:Number;
var percent:Number;
fm_bar.addEventListener(Event.ENTER_FRAME, load_progress);
function load_progress(e:Event):void
{
loaded_bytes = stage.loaderInfo.bytesLoaded;
total_bytes = stage.loaderInfo.bytesTotal;
if (total_bytes == 0) total_bytes = 1;
percent = Math.round(loaded_bytes / total_bytes * 100);
fm_bar.scaleX = percent * 0.01;
loader_info.text = "loading..." + percent + "%";
if(percent == 100)
{
fm_bar.removeEventListener(Event.ENTER_FRAME, load_progress);
play();
}
}
and now it gives me this error: 62199900% ![]()
Copy link to clipboard
Copied
that looks like an int or uint type error but there's nothing you've shown in this thread that would cause that.
i think someone will need to download and correct your file for you. or, at least, i'm unable to offer anything more in this forum.
Copy link to clipboard
Copied
Thanks Kglad..
I uploaded the file to:
www.dreamgem.net/LOADER_TEST/LOADER_TEST.zip
This is not the actual file(Can't load it before Launch - company rules) but it's the exact replica of the set up - and it behaves exactly like the actual file I"m working on..
Copy link to clipboard
Copied
(someone else may download and correct your file, but i only do that if i'm hired to fix a problem.)
Copy link to clipboard
Copied
Sure - I totally understand
I'll leave it here just in case someone has a solution before I find one. I REALLY appreciate all your help!
Lana
Copy link to clipboard
Copied
Put in a trace on:
stage.loaderInfo.bytesLoaded;
stage.loaderInfo.bytesTotal;
and see what values they have initially.
Also try and add parenthesis around percent before multiplying with 100. Could be that dividing and multiplying don't have the same priority as you think.
Copy link to clipboard
Copied
Thanks Spogg - I'll check it out
Get ready! An upgraded Adobe Community experience is coming in January.
Learn more