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

Join 118,589 Programmers for FREE! Ask your question and get quick answers from experts. There are 820 online right now! We've got more than 500 tutorials and 2,000 snippets. Join and find out why Dream.In.Code is the #1 programming help community on the internet! 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
post 4 Aug, 2008 - 12:16 PM
Post #1


D.I.C Head

**
Joined: 10 Jul, 2007
Posts: 131


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
}
Attached File  test.zip ( 1.4mb ) Number of downloads: 6
User is offlineProfile CardPM

Go to the top of the page


BetaWar
post 4 Aug, 2008 - 04:32 PM
Post #2


#include <soul.h>

Group Icon
Joined: 7 Sep, 2006
Posts: 1,669



Thanked 64 times

Dream Kudos: 1075
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 online!Profile CardPM

Go to the top of the page

tzer
post 6 Aug, 2008 - 04: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

Go to the top of the page

bmcc81
post 12 Aug, 2008 - 07:27 AM
Post #4


D.I.C Head

**
Joined: 10 Jul, 2007
Posts: 131


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

Go to the top of the page

tzer
post 12 Aug, 2008 - 07: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 - 07:20 PM
User is offlineProfile CardPM

Go to the top of the page

bmcc81
post 13 Aug, 2008 - 06:31 AM
Post #6


D.I.C Head

**
Joined: 10 Jul, 2007
Posts: 131


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

Go to the top of the page

tzer
post 13 Aug, 2008 - 07: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 - 07:59 PM
User is offlineProfile CardPM

Go to the top of the page

Fast ReplyReply to this topicStart new topic
Time is now: 10/11/08 07:51PM

Live Help!

Tutorials

Programming

Web Development

Reference Sheets

Code Snippets

Bye Bye Ads

Free DIC T-Shirt

T-Shirt Example

Related Sites

Monthly Drawing

Thumb Drive

Partners

Top Contributors

Top 10 Kudos This Month