Skip to main content
Known Participant
July 30, 2010
Answered

Moviecliploader onprogress not working

  • July 30, 2010
  • 1 reply
  • 798 views

Hello,

I am using a moviecliploader to load landing.swf into a mcholder in parent.swf. Now even though the movie is loading fine, I am not able to display the loading percentage. The percentage always shows 100%. I am trying make a loader graphic run as per the percentage value, but since it is always at 100 the graphic does not work. I have tried testing it on the server as well, same thing, no loader graphic.

Can anyone tell me why this is happening? Am I supposed to use a recurring function within the onloadProgress function???

Any help will be greatly appreciated.

This topic has been closed for replies.
Correct answer Ned Murphy

One thing you should do is be sure to clear your cache when testing this.  You should test it live on a server as well, or at least use the simulate download feature of the player if you have it.  The file being loaded might be too small or might be readily available in memory such that the loading doesn't get tested properly.

Here's a couple things regarding the coding...

While it depends on how large a file is being loaded, chances are you won't be hitting the exact prcnt values that your code tests for, so you will probably end up skipping frames and not seeing traces for all cases.  If you put a trace in the beginning of that function you will be able to see if the prcnt values are == to any of the tested values.

I don't know what you have going on inside the ldgraphic movieclip, but using gotoAndPlay could be a problem if the file being loaded comes in slowly enough that you have repeats of values.  You may be better off using gotoAndStop if that movieclip stops in each frame you tell it to go to.

1 reply

Ned Murphy
Legend
July 30, 2010

Can you show/explain the code you are using?

aditi_bkAuthor
Known Participant
July 30, 2010

Hi Ned,

The code is:

var loader:MovieClipLoader = new MovieClipLoader();

var ldrlistener = new Object();

loader.addListener(ldrlistener);

ldrlistener.onLoadStart = function(_mc:MovieClip) {
    trace("load started");
};

ldrlistener.onLoadProgress = function(_mc:MovieClip, loaded:Number, total:Number) {
    var prcnt:Number = Math.floor( ( loaded/total ) * 100 );

    if(prcnt==10)                    //diff labels within ldgraphic
    {
        _root.ldgraphic.gotoAndPlay("ten");
        trace("loading:10");
    }
    if(prcnt == 15) {_root.ldgraphic.gotoAndPlay("fifteen");
                    trace("loading:15");}
    if(prcnt == 20) {_root.ldgraphic.gotoAndPlay("twenty");
                    trace("loading:20");}
    if(prcnt == 25) {_root.ldgraphic.gotoAndPlay("twentyfive");
                    trace("loading:25");}
    if(prcnt == 30) {_root.ldgraphic.gotoAndPlay("thirty");
                        trace("loading:30");}
    if(prcnt == 40) {_root.ldgraphic.gotoAndPlay("forty");
                    trace("loading:40");}
    if(prcnt == 50) {_root.ldgraphic.gotoAndPlay("fifty");
                    trace("loading:50");}
    if(prcnt == 55) {_root.ldgraphic.gotoAndPlay("fiftyfive");
                    trace("loading:55");}
    if(prcnt == 60) {_root.ldgraphic.gotoAndPlay("sixty");
                    trace("loading:60");}
    if(prcnt == 70) {_root.ldgraphic.gotoAndPlay("seventy");
                    trace("loading:70");}
    if(prcnt == 80) {_root.ldgraphic.gotoAndPlay("eighty");
                    trace("loading:80");}
    if(prcnt == 100) {_root.ldgraphic.gotoAndPlay("hundred");
                    trace("loading:100");}
};

ldrlistener.onLoadInit = function(_mc:MovieClip) {
    _root.ldgraphic._alpha = 0;              //the loader graphic become invisible after load
    trace("load completed");
};

loader.loadClip("home.swf",_root.mc_load);

Now only "loading:100" is shown in the output and the loader graphic becomes invisible. home.swf starts playing. I know that the loader graphic is visible because when I removed the _alpha line I could see the graphic in its 100% state. Also, when I did a trace of prcnt values, it only shows 100. I checked this on the server as well, still the same thing happens.

Ned Murphy
Ned MurphyCorrect answer
Legend
July 30, 2010

One thing you should do is be sure to clear your cache when testing this.  You should test it live on a server as well, or at least use the simulate download feature of the player if you have it.  The file being loaded might be too small or might be readily available in memory such that the loading doesn't get tested properly.

Here's a couple things regarding the coding...

While it depends on how large a file is being loaded, chances are you won't be hitting the exact prcnt values that your code tests for, so you will probably end up skipping frames and not seeing traces for all cases.  If you put a trace in the beginning of that function you will be able to see if the prcnt values are == to any of the tested values.

I don't know what you have going on inside the ldgraphic movieclip, but using gotoAndPlay could be a problem if the file being loaded comes in slowly enough that you have repeats of values.  You may be better off using gotoAndStop if that movieclip stops in each frame you tell it to go to.