Go Back   kirupaForum > Flash > ActionScript 1.0/2.0

Reply
 
Thread Tools Display Modes
Old 12-01-2009, 11:10 AM   #1
gooflett
Registered User
partial preloader help

I found this code on the best of Kirupa and was wondering how I could modify this code to go to and play frame 2 after it has loaded a certain number of kilobytes or a certain percentage.

I would like it it to preload 1/4 of the total kb and then play. Currently it loads the whole enchilada.

Thanks for the help.


//here we are getting the total bytes and the number of
//bytes that have been loaded so far, of the movie, and
//dividing it by 1000 in order to come up with killobytes.
//we set two variables to be equal to these two statements
//like so
totalK=getBytesTotal()/1000;
loadedK=getBytesLoaded()/1000;
//remaining K is just the first variable, minus the second.
remainingK=totalK-loadedK;
//percentage of K loaded is just the second variable divided
//by the first, and then mutliplied by 100.
percentageK=(loadedK/totalK)*100;
//here we set the bar movie clip to scale, left/right by the
//amount of the percentage variable.
setProperty("bar",_xscale,percentageK);
//here is our break out.. if the amount of K loaded is greater
//than the total K of the movie, AND (that's what && means..
//both conditions have to be true) the total K is NOT equal to
//0, then goto the third frame.
if(loadedK>=totalK&&totalK!=0){
gotoAndPlay(3);
}
gooflett is offline   Reply With Quote

Sponsored Links (Guests Only) - Register | Need Help?
 

Old 12-01-2009, 11:23 AM   #2
glosrfc
Registered User
 
glosrfc's Avatar
Location Halley Research Station, Latitude 75°35' S, Longitude 26°39' W, Brunt Ice Shelf, Coats Land, Antarctica

Posts 4,158
totalK is the total filesize of your SWF expressed in Kilobytes (by dividing it by 1000)
loadedK is the number of Kilobytes that has been loaded

totalK / 4 is the same as 25% of your total filesize. So you can change the last lines to:
ActionScript Code:
if (loadedK >= (totalK / 4)) {
   gotoAndPlay(2);
}

__________________
©2006 GlosRFC - Searching 8,168,684,336 brain cells
glosrfc is offline   Reply With Quote
Old 12-01-2009, 01:22 PM   #3
gooflett
Registered User
For some reason that is not working. It loads 100% of the movie and then plays. What else do you think we could try? Why isn't flash dividing like it should?

You can download the file I am working on here. http://d01.megashares.com/dl/80ad611/loader.fla.zip
gooflett is offline   Reply With Quote
Old 12-01-2009, 01:31 PM   #4
glosrfc
Registered User
 
glosrfc's Avatar
Location Halley Research Station, Latitude 75°35' S, Longitude 26°39' W, Brunt Ice Shelf, Coats Land, Antarctica

Posts 4,158
Typically, that kind of code has an instruction on frame 2 to go back to frame 1; that's how it manages to update the variables. So I doubt that you can break out to frame 2...try using another frame instead.

__________________
©2006 GlosRFC - Searching 8,168,684,336 brain cells
glosrfc is offline   Reply With Quote
Old 12-01-2009, 01:53 PM   #5
gooflett
Registered User
Quote:
Originally Posted by glosrfc View Post
Typically, that kind of code has an instruction on frame 2 to go back to frame 1; that's how it manages to update the variables. So I doubt that you can break out to frame 2...try using another frame instead.
I think this is working. The only thing is it hangs on frame 2 for a second before it goes to frame 3. Not sure if there is a fix for this or not. But this helps a ton. Let me know if you have an idea why it might hang on frame 2.

Frame 1
//here we are getting the total bytes and the number of
//bytes that have been loaded so far, of the movie, and
//dividing it by 1000 in order to come up with killobytes.
//we set two variables to be equal to these two statements
//like so
totalK=getBytesTotal()/1000;
loadedK=getBytesLoaded()/1000;
//remaining K is just the first variable, minus the second.
remainingK=totalK-loadedK;
//percentage of K loaded is just the second variable divided
//by the first, and then mutliplied by 100.
percentageK=(loadedK/totalK)*100;
//here is our break out.. if the amount of K loaded is greater
//than the total K of the movie, AND (that's what && means..
//both conditions have to be true) the total K is NOT equal to
//0, then goto thesecond frame.
if (loadedK >= (totalK / 8)) {
gotoAndPlay(3);
}

Frame 2
gotoAndPlay(1);

Frame 3
The movie


Are you really in Antartica? If so... that is awesome!
gooflett is offline   Reply With Quote
Old 12-01-2009, 03:13 PM   #6
glosrfc
Registered User
 
glosrfc's Avatar
Location Halley Research Station, Latitude 75°35' S, Longitude 26°39' W, Brunt Ice Shelf, Coats Land, Antarctica

Posts 4,158
You might want to check out this guide to preloading:
http://www.senocular.com/flash/tutorials/preloading/

Read the sections on Progress Indicating Preloaders and Loading Complications

__________________
©2006 GlosRFC - Searching 8,168,684,336 brain cells
glosrfc is offline   Reply With Quote
Reply


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -4. The time now is 05:16 PM.

SUPPORTERS:

kirupa.com's fast and reliable hosting provided by Media Temple. flash components
Creative web apps. Make your own free flash banners and photo slideshows.
Check out the great, high-quality flash extensions. Buy or sell stock flash, video, audio and fonts for as little as 50 cents at FlashDen.

Flash Transition Effects

Flash Effect Tutorials

Digicrafts Components
Flash effects. Art without coding. Upload, publish, deliver. Secure hosting for your professional or academic video, presentations & more. Screencast.com
Streamsolutions Content Delivery Networks Flipping Book - page flip flash component.
Flash-Gallery.com - Get your flash photo gallery (flash component or swf gallery Learn how to advertise on kirupa.com
 

cdn
content delivery network (cdn)

Powered by vBulletin® Version 3.8.4
Copyright ©2000 - 2010, Jelsoft Enterprises Ltd. Copyright 2010 - kirupa.com Copyright 2010 - kirupa.com