Flash preloader including percent of HTML loaded.

  • s15199d
  • Expert
  • Expert
  • User avatar
  • Posts: 524
  • Loc: NC, USA

Post 3+ Months Ago

This question crosses a few different forums. So, I thought I'd put it here, and if the Mods wanna move it that's cool.

My question is whether there is code to tie a preloader w/ the actual % loaded of a page. Or whether you just time the load of your page, and set the preloader to run for that length of time.

This question isn't of dier importance. I'm merely intrigued. This is more for my edification than anything else.
  • Anonymous
  • Bot
  • No Avatar
  • Posts: ?
  • Loc: Ozzuland
  • Status: Online

Post 3+ Months Ago

  • joebert
  • Fart Bubbles
  • Genius
  • User avatar
  • Posts: 13503
  • Loc: Florida

Post 3+ Months Ago

//Title edited

I opened this topic with the intent of locking it when I seen "Flash Preloader..." for the title.

After reading the question, I'm leaving it be while I look into this topic :D
  • s15199d
  • Expert
  • Expert
  • User avatar
  • Posts: 524
  • Loc: NC, USA

Post 3+ Months Ago

Thanx joebert!
  • joebert
  • Fart Bubbles
  • Genius
  • User avatar
  • Posts: 13503
  • Loc: Florida

Post 3+ Months Ago

The only things i've found use timing as you mentioned :-/

This would be a little inaccurate but you could pull a byte average per second from the flash preloader and have flash simulate additional preloading from that.

Honestly, I'm not seeing the point of doing it yet I'm interested to see what others have to say about it :D
  • s15199d
  • Expert
  • Expert
  • User avatar
  • Posts: 524
  • Loc: NC, USA

Post 3+ Months Ago

well I was building a preloader...nothing fancy the other day...and I was like...well what if my loader finishes and the page isn't done loading yet...or if you have one of those preloader that shows % complete...and the loader says like 90%, but the page is really only like 10% done loading...make any since???

but mainly I was just wondering if it was doable. I was wondering if you could...moreso than if you should.
  • Witch_Doctor
  • Born
  • Born
  • Witch_Doctor
  • Posts: 1

Post 3+ Months Ago

im so happy i did a search for preloader scrpit tutorial and this forum was one of the first few, i now have a place i can get some help with this stuff.


well it can be both timed and % done, i recently went and got flash games off the net and a few have preloaders they just go strate to the game after i got them but as i played them online they loaded slowly, but people could just set it up to go a certian amount of time, i belive this whould look bad for it shows the programer didnt know what (s)he was doing, i if yall have figured it out please post i am trying to make one, i have the pic all i need is to add the script.
  • elibol
  • Novice
  • Novice
  • elibol
  • Posts: 29

Post 3+ Months Ago

i dont really understand the problem, to calculate the percentage loaded for a movieclip:

Code: [ Select ]
var Percentage=int((100/movieclip.bytesTotal())*movieclip.bytesLoaded());


use integer so u dont get franctions...

for _root (meaning the whole file):

Code: [ Select ]
var Percentage=int((100/_root.bytesTotal())*_root.bytesLoaded());


now you must put this in a loop, the most efficient way of doing this is to attach a listener to the value being modified, in this case bytesLoaded().

you could also assign a function to the onEnterFrame event handler.

i think this is what you needed ?

also if you want to just show kb's loaded or mb's instead of bytes then divide the bytes by 1000 to move the decimal down 3 spaces to show kb's. if you want the fractions cut off use the int() function to knock them off, then you can divide by another 1000 and move the decimal again to have mb's value.
  • joebert
  • Fart Bubbles
  • Genius
  • User avatar
  • Posts: 13503
  • Loc: Florida

Post 3+ Months Ago

elibol wrote:
i dont really understand the problem, to calculate the percentage loaded for a movieclip:

Code: [ Select ]
var Percentage=int((100/movieclip.bytesTotal())*movieclip.bytesLoaded());


use integer so u dont get franctions...

for _root (meaning the whole file):

Code: [ Select ]
var Percentage=int((100/_root.bytesTotal())*_root.bytesLoaded());


now you must put this in a loop, the most efficient way of doing this is to attach a listener to the value being modified, in this case bytesLoaded().

you could also assign a function to the onEnterFrame event handler.

i think this is what you needed ?

also if you want to just show kb's loaded or mb's instead of bytes then divide the bytes by 1000 to move the decimal down 3 spaces to show kb's. if you want the fractions cut off use the int() function to knock them off, then you can divide by another 1000 and move the decimal again to have mb's value.


I think they want to include the HTML in with it, (movie.swf + page.html) = totalSize;

If you do an all flash site, problem solved. (the <1 kb html to embed the swf wont matter much)
If you have umpteen kb worth of HTML content & umpteen kb worth of flash content then it's a problem getting accurate preloaders.
  • Platinum•
  • Novice
  • Novice
  • User avatar
  • Posts: 25
  • Loc: Australia

Post 3+ Months Ago

I think your code is wrong...

it says
" **Error** Scene=Scene 1, layer=Layer 1, frame=1:Line 1: Syntax error.
instanceName.onEnterFrame var Percentage = int((100/_root.bytesTotal())*_root.bytesLoaded());

Total ActionScript Errors: 1 Reported Errors: 1 "
  • joebert
  • Fart Bubbles
  • Genius
  • User avatar
  • Posts: 13503
  • Loc: Florida

Post 3+ Months Ago

Platinum• wrote:
I think your code is wrong...

it says
" **Error** Scene=Scene 1, layer=Layer 1, frame=1:Line 1: Syntax error.
instanceName.onEnterFrame var Percentage = int((100/_root.bytesTotal())*_root.bytesLoaded());

Total ActionScript Errors: 1 Reported Errors: 1 "


If line 1 of what you used to test that looks like,
Code: [ Select ]
instanceName.onEnterFrame var Percentage = int((100/_root.bytesTotal())*_root.bytesLoaded());

The make it look like this & tell me if you still get an error,
Code: [ Select ]
instanceName.onEnterFrame = function(){
   var Percentage = int((100/_root.bytesTotal())*_root.bytesLoaded());

}
  1. instanceName.onEnterFrame = function(){
  2.    var Percentage = int((100/_root.bytesTotal())*_root.bytesLoaded());
  3. }
  • lostinbeta
  • Guru
  • Guru
  • User avatar
  • Posts: 1402
  • Loc: Philadelphia, PA

Post 3+ Months Ago

Flash cannot read the percentage of the HTML file loaded, only the content within the Flash file.

You can make an HTML preloader using Javascript, but even that is limited in it's overall ability to detect the load percent of a page (and only works for images not all content).

So in conclusion, you can do an HTML preloader, then have a seperate preloader in your movie, or you can just have the preloader in your movie and let the HTMl content load when it loads (I think I would recommend this method, save yourself the trouble for something that really isn't that important)
  • mico
  • Beginner
  • Beginner
  • User avatar
  • Posts: 54
  • Loc: Neo Universe

Post 3+ Months Ago

is that script can be used to load the file that contain more than 1 frames? i mean if the swf has been loaded 100% for all frames, then the swf file will be shown (not before all the frames loaded 100%)..

Post Information

  • Total Posts in this topic: 12 posts
  • Users browsing this forum: No registered users and 8 guests
  • You cannot post new topics in this forum
  • You cannot reply to topics in this forum
  • You cannot edit your posts in this forum
  • You cannot delete your posts in this forum
  • You cannot post attachments in this forum
 
 

© 1998-2014. Ozzu® is a registered trademark of Unmelted, LLC.