Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
  • 한국 커뮤니티
0

Preloader in as3

Explorer ,
Aug 23, 2010 Aug 23, 2010

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);
    }

}

TOPICS
ActionScript
2.7K
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Aug 23, 2010 Aug 23, 2010

the problem's not in that code.  you're doing something else to cause the problem.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Guest
Aug 23, 2010 Aug 23, 2010

Define

total variable and try one more time

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Aug 23, 2010 Aug 23, 2010

it is defined.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
Aug 23, 2010 Aug 23, 2010

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...

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
Aug 24, 2010 Aug 24, 2010

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");
    }
}

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
Aug 24, 2010 Aug 24, 2010

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...

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Aug 24, 2010 Aug 24, 2010

the code you last showed wouldn't cause that output.  you're doing something else to cause that problem.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
Aug 25, 2010 Aug 25, 2010

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?

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
Aug 25, 2010 Aug 25, 2010

No - other code doesn't affect it... I treid removing it..


Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Aug 25, 2010 Aug 25, 2010

make sure you're using the html page published by flash.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
Aug 25, 2010 Aug 25, 2010

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% 

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Aug 25, 2010 Aug 25, 2010

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.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
Aug 25, 2010 Aug 25, 2010

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..

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Aug 25, 2010 Aug 25, 2010

(someone else may download and correct your file, but i only do that if i'm hired to fix a problem.)

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
Aug 25, 2010 Aug 25, 2010

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

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Guest
Aug 26, 2010 Aug 26, 2010

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.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
Aug 26, 2010 Aug 26, 2010
LATEST

Thanks Spogg - I'll check it out

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines