Welcome to Dream.In.Code
Getting Help is Easy!

Join 136,847 Programmers for FREE! Get instant access to thousands of experts, tutorials, code snippets, and more! There are 1,625 people online right now. Registration is fast and FREE... Join Now!




Loading only starts at 37%

 
Reply to this topicStart new topic

Loading only starts at 37%, Weird loading starts late

bmcc81
4 Aug, 2008 - 11:16 AM
Post #1

D.I.C Head
**

Joined: 10 Jul, 2007
Posts: 164


My Contributions
Hi,


I'm trying to get this loader to work correctly. Can anyone tell me why the loader only starts at 37% or if there is a way to make it start at 0%

thanks,

CODE
onClipEvent (load)
{
    total = _parent.getBytesTotal();
}
onClipEvent (enterFrame)
{
    loaded = _parent.getBytesLoaded();
    percent = int(loaded / total * 100);
    _root.loade.P = percent + "%";
    gotoAndStop(percent);
    if (loaded == total)
    {
       _parent.gotoAndPlay(2);
    } // end if
}

User is offlineProfile CardPM
+Quote Post

BetaWar
RE: Loading Only Starts At 37%
4 Aug, 2008 - 03:32 PM
Post #2

#include <soul.h>
Group Icon

Joined: 7 Sep, 2006
Posts: 2,031



Thanked: 82 times
Dream Kudos: 1175
My Contributions
I am going to take a guess and say that it is starting at 37% because it has cached that much of the information to your computer. Thus it doesn't need to load each time. The equation looks correct, though you may want to change _parent to _root just to make sure that it is going off of the flash swf as a whole.
User is offlineProfile CardPM
+Quote Post

tzer
RE: Loading Only Starts At 37%
6 Aug, 2008 - 03:33 AM
Post #3

New D.I.C Head
*

Joined: 6 Aug, 2008
Posts: 4



Thanked: 1 times
My Contributions
this is the weakness for this preloading technique, flash only start showing after finish loaded 1st frame which including linkage object that load at 1st frame. Meaning that when your flash start showing, it already loaded some data at 1st frame and in your case is 37%.

it cannot be started as clean as 0% as it will at least loaded your loading object (e.g. loading bar and text that showing loading progress) before showing up. What you can do is try to move away objects appear in 1st frame and minimize linkage objects.

there is other trick I tried before which subtract the total bytes in 1st frame in your loading calculation. you can find total bytes in 1st frame on the "bandwidth profiler".

loaded_percentage = (loaded_bytes - 1stframe_bytes) / (total_bytes - 1stframe_bytes) * 100;

Hope this answer your need.
User is offlineProfile CardPM
+Quote Post

bmcc81
RE: Loading Only Starts At 37%
12 Aug, 2008 - 06:27 AM
Post #4

D.I.C Head
**

Joined: 10 Jul, 2007
Posts: 164


My Contributions
I'm having trouble applying this to my formula.

Could you give me a hand?

CODE


onClipEvent (load)
{
    total = _parent.getBytesTotal();
}
onClipEvent (enterFrame)
{
    
    loaded = _parent.getBytesLoaded();
    percent = int(loaded / total * 100);
    _root.loade.P = percent + "%";
    gotoAndStop(percent);
    if (loaded == total)
    {
       _parent.gotoAndPlay(2);
    } // end if
}
//loaded_percentage = (loaded_bytes - 1stframe_bytes) / (total_bytes - 1stframe_bytes) * 100;

Thanks,
User is offlineProfile CardPM
+Quote Post

tzer
RE: Loading Only Starts At 37%
12 Aug, 2008 - 06:10 PM
Post #5

New D.I.C Head
*

Joined: 6 Aug, 2008
Posts: 4



Thanked: 1 times
My Contributions
CODE

onClipEvent (load)
{
    total = _parent.getBytesTotal();
    firstframebytes = 36890; //bytes amount at first frame, get this value at bandwidth profiler while test movie
}
onClipEvent (enterFrame)
{
    loaded = _parent.getBytesLoaded();
    percent = int((loaded - firstframebytes) / (total - firstframebytes) * 100);
    _root.loade.P = percent + "%";
    gotoAndStop(percent);
    if (loaded == total)
    {
       _parent.gotoAndPlay(2);
    } // end if
}

please noted that you have to update the value of "firstframebytes" if the bytes amount at 1st frame is changed when you modified the movie. Please let me if this work.

This post has been edited by tzer: 12 Aug, 2008 - 06:20 PM
User is offlineProfile CardPM
+Quote Post

bmcc81
RE: Loading Only Starts At 37%
13 Aug, 2008 - 05:31 AM
Post #6

D.I.C Head
**

Joined: 10 Jul, 2007
Posts: 164


My Contributions
QUOTE(tzer @ 12 Aug, 2008 - 07:10 PM) *

CODE

onClipEvent (load)
{
    total = _parent.getBytesTotal();
    firstframebytes = 36890; //bytes amount at first frame, get this value at bandwidth profiler while test movie
}
onClipEvent (enterFrame)
{
    loaded = _parent.getBytesLoaded();
    percent = int((loaded - firstframebytes) / (total - firstframebytes) * 100);
    _root.loade.P = percent + "%";
    gotoAndStop(percent);
    if (loaded == total)
    {
       _parent.gotoAndPlay(2);
    } // end if
}

please noted that you have to update the value of "firstframebytes" if the bytes amount at 1st frame is changed when you modified the movie. Please let me if this work.



Thanks Man,

Just one thing I don't understand?

It's the line - gotoAndStop(percent);
Does it just make mthe preloader start or ...?
Thanks again




User is offlineProfile CardPM
+Quote Post

tzer
RE: Loading Only Starts At 37%
13 Aug, 2008 - 06:58 PM
Post #7

New D.I.C Head
*

Joined: 6 Aug, 2008
Posts: 4



Thanked: 1 times
My Contributions
gotoAndStop(percent) didn't make the preloader start. It just update which frame inside the movieclip should go. Take a look inside the movieclip, you can see a tweening from 0% to 100% in 100 frame.

onClipEvent (enterFrame){} code on the movieclip make the movieclip run the preloader code run every frame. If your movie is running at 30fps, meaning that this code will be run 30 times every second.

This post has been edited by tzer: 13 Aug, 2008 - 06:59 PM
User is offlineProfile CardPM
+Quote Post

Fast ReplyReply to this topicStart new topic
Time is now: 12/3/08 06:04PM

Live Help!

Tutorials

Programming

Web Development

Reference Sheets

Code Snippets

DIC Chatroom

Bye Bye Ads

Monthly Drawing

Thumb Drive

Top Contributors

Top 10 Kudos This Month