hey, I wonderd if anyone could help me make a forced preloader? My site is small so the preloader would just show up for one second and then go to the site, but i want it to go from 1 to 100, without going like 20 to 80 then done…
Can anyone help? I’ll be very gratefull. My preloader bar will have a width of 200.
But, does this actually load the page, seems like it just regulate the size of the bar…but I need a real preloader, but that dont just jump from 20 to 80. So it will be a normal preloader, but it takes atleast 2 seconds, and if the user has modem, it will take the loading time…
This just seems a little pointless but what you could do is have a fake preloader as outlined above and a genuine one and switch between the 2 dependant upon the speed it initially starts loading.(There are tutorials for measuring this on flashkit and probably here too)
Yah, I guess. But isnt it possible setting so the preloader in the transition just goes from 1 to 100? Usually it just goes from 20 to 80 then done, but I would very much like it to go all the way without to much difficulties…but still actually load the page.
You with me?
well… yeah…
have a variable called realPercent which is calculated as outlined on the tutorial for the real preloader, then have this code on frame1 as well:
if(!intervalStarted){
intervalStarted=1
fakePercentInt = setInterval(function(){
fakePercent++
},100) //again, change the 100 to a speed of your choice ;)
}
if(realPercent<=fakePercent){
clearInterval(fakePercentInt)
}
else if(realPercent>fakePercent){
intervalStarted=0
}
else if(realPercent==fakePercent==100){
gotoAndStop(3)
}
// below is an.... optional... extra ;) lol
else{
fakePercent = "woops... an error occurred..."
}
and just set your text box equal to the variable fakePercent and have the _width of your preloader bar calculated as 2fakePercent*
that should do the trick neway… (just written as a post, not copied and pasted as tried&tested code…)
your preloader should have somewhere in it something like
percent = (bytesLoaded()/bytesTotal())*100
change it to this:
realPercent = (bytesLoaded()/bytesTotal())*100
then add the codea bove on the first frame.
look at the tutorial again if your still lost…
but then again, if it still doesnt make any sense we could be talking about diff tuts… so post the link and ill look…
thats becausse your setting your properties to realPercent which is not what you want, try this:
bytesLoaded = Math.round(_root.getBytesLoaded());
bytesTotal = Math.round(_root.getBytesTotal());
//getPercent = bytes_loaded/bytes_total; // Just to remember what the old one was
realPercent = (bytesLoaded/bytesTotal)*100
_root.loadBar._width = fakePercent*2; //max width is 2*100 = 200 as opposed to what you had as 100*100 = 10000
_root.loadText = fakePercent+"% Loaded"; //no need to round or times as fakePercent is incremented by 1 each time rather than being loaded/total
if(!intervalStarted){
intervalStarted=1
fakePercentInt = setInterval(function(){
fakePercent++
running=1 //noticed a minor error with my code here...
},17) //again, change the 100 to a speed of your choice ;)
}
if(realPercent<=fakePercent){
clearInterval(fakePercentInt)
running=0
}
else if(realPercent>fakePercent && running==0){
intervalStarted=0
}
else if(realPercent==fakePercent==100){
gotoAndStop(3)
}
// below is an.... optional... extra ;) lol
else{
fakePercent = "woops... an error occurred..."
}
how about this i didnt look it over that well but it does the thing you wanted so.
Note: prophet you wrote all that code you could of just sent him a fla, hes a visual person i think lol.
yeah i had to fiddle with the failsafes… sorry about that…
heres a working example that (on a slow connection) stops if the realPercent gets behind the fakePercent and restarts if realPercent is at least 5 ahead of fakePercent or if realPercent has reached 100… looks pretty neat if i dont say so myself lol
bytesLoaded = Math.round(_root.getBytesLoaded());
bytesTotal = Math.round(_root.getBytesTotal());
//getPercent = bytes_loaded/bytes_total; // Just to remember what the old one was
realPercent = (bytesLoaded/bytesTotal)*100
_root.loadBar._width = fakePercent*2; //max width is 2*100 = 200 as opposed to what you had as 100*100 = 10000
_root.loadText = fakePercent+"% Loaded"; //no need to round or times as fakePercent is incremented by 1 each time rather than being loaded/total
if(!firstTime){
firstTime=1
fakePercent=0
}
if(intervalStarted!=1){
intervalStarted=1
clearInterval(fakePercentInt)
fakePercentInt = setInterval(function(){
fakePercent++
trace(realPercent)
},20) //again, change the 100 to a speed of your choice ;)
}
if(fakePercent>realPercent){
clearInterval(fakePercentInt)
}
else if(fakePercent<(realPercent-5)||realPercent>=100){
intervalStarted=0
}
if(fakePercent>=100){
gotoAndStop(3)
clearInterval(fakePercentInt)
}
fraid i cant help u much with the mp3 player… i havent really dabbled in sound yet… nor xml… sorry!