Can I partially load?

I have a 2.6mb Flash MX video. I attached a preloader to it, but now the movie won’t run until the preloader reaches 100%. Using the bytesLoaded function. Wondering is there any way to start playing the movie once say 50% has been reached. Since it is a 2.6mb file, it takes a while and I would like to run it, while the remaining 50% is loading… Possible?

do you use

ifFrameLoaded();

or

if (bytestotal-bytesloaded == 0); --or sumthiin’ like that

so anyway change it to:

bytespercent = (bytesloaded/bytestotal)*100
if (bytespercent == 50) {
}

You have to change the “bytestotal” and “bytesloaded” to the variables you have. also check if ya already have sumthin’ like bytespercent which has a value of percents loaded then you don’t have to add that line but you have to change “bytespercent” in the IF statement to the one that ya have…
tip: bytestotal is defined by “_getBytesTotal” and bytesloaded is defined by “_getBytesLoaded” by these things it’s easier to locate the variables…

Here is what I have. It is not working correctly, will not display the percentage. Did I mess it up?

stop();
myInterval = setInterval(preloader, 10);
function preloader() {
if (_framesloaded>=100) {
play();
clearInterval(myInterval);
}
progressBar._xscale = (_framesloaded/_totalframes)*100;
}
myTextField.text=Math.round(_framesloaded()/_totalframes()*100)+"%";

you should not place that stop(); action first. It will stop the movie from reading everything else in that frame.

secondly, you have to have a loop to continualy check on the code.

Thirdly… can you explain what that whole “interval” thing is about? I’m not sure I understand what you’re trying to accomplish with that.

PS - You should check out the speach Moock made on the subject at the Flash forward convention. It can be found at www.moock.org.

david -

stop doesn’t prevent execution of the rest of the code in the frame, give it a try:


stop();
trace("i didn't stop!");

gsdesigns -

i’m not sure here, but i think you might need to path to all your relevant details in that function.

i would recommend swapping getBytesLoaded() and getBytesTotal() in place of _framesloaded and _totalframes respectively. i also note that your treating them as properties in one instance (no () at the end) and methods in another (with the ()).

try tracing that last line instead of assigning it to myTextField:


trace((_root.getBytesLoaded()/_root.getBytesTotal()*100)+"%");

that will give you an idea of where to start troubleshooting.

Are you sure supra?? I’ve read in a couple of books that it may or may not stop reading the rest of the code in a frame.

Though they may have been refering to code on different layers… but I’m not sure why that would make a diff.

If I’m mistaken… sorry for being misleading.

Also… since I got you here supra… why would you replace bytes for frames in the bytesLoaded statement? What would he gain by doing so except a less accurate read of the data?

Are you sure supra?? I’ve read in a couple of books that it may or may not stop reading the rest of the code in a frame.

did you try the example? works for me every time.

different layers might make a difference … flash can be a buggy animal sometimes.

Also… since I got you here supra… why would you replace bytes for frames in the bytesLoaded statement? What would he gain by doing so except a less accurate read of the data? *

sorry? less accurate? frames tend not to be evenly loaded byte wise, ie. some frames will contain (vastly) more data than others. that makes your load meter stall and jump as it encounters ‘heavy’ frames.

a more accurate read is precisely what you do gain.