shuga
March 17, 2003, 8:20pm
1
i have an animation that can be 100 frames long but it’s not necissarily so.
i would like this animation to be my preloader basically i want to write a script that gets the bytesloaded/totalbytes and makes a percentage and then goes to the frame corresponding to the percentage
so if my animation is 50 frames long and the movie is found to be 50% loaded by the script then the playhead should be on frame 25.
does that make sense?
thanks very much for your help
system
March 17, 2003, 8:25pm
2
Well you need to take whats loaded, divide it by the total. multiply by 100 and then tell the movie to gotoAndStop at that frame…
nTotal = _root.getBytesTotal()/1000;
nLoad = _root.getBytesLoaded()/1000;
nPrecent = Math.round((nLoad/nTotal)*100);
_root.gotoAndStop(nPercent);
Now that code will have to go in a movieclip with an enterFrame command, and that moveclip will have to be present in every frame…
system
March 17, 2003, 9:25pm
3
no … that will only work if you have a 100 frame clip
b/c it goes to the frame that is the percentage number
look at the example i typed … so if my animation is 50 frames long and the movie is found to be 50% loaded by the script then the playhead should be on frame 25.
system
March 17, 2003, 9:28pm
4
nNumber = Math.round(_totalframes * (nPercent/100))
gotoAndStop(nNumber)
system
March 17, 2003, 10:22pm
5
here’s what i have
nTotal = _root.getBytesTotal()/1000;
nLoad = _root.getBytesLoaded()/1000;
nPercent = Math.round((nLoad/nTotal)*100);
percentage.text = nPercent;
nNumber = Math.round(_totalframes*(nPercent/100));
if (nLoad < nTotal) {
gotoAndStop(nNumber);
}
if (nLoad == nTotal) {
gotoAndPlay ("main", 1);
}
why isn’t it working?
percentage.text is a text box i have in it’s own layer that i want to display the current percentage in text form while the load is in progress
system
March 17, 2003, 10:41pm
6
Do you have a loop?
_root.onEnterframe = function() {
//code goes here
}
system
March 17, 2003, 11:00pm
7
like this?
nTotal = _root.getBytesTotal()/1000;
nLoad = _root.getBytesLoaded()/1000;
nPercent = Math.round((nLoad/nTotal)*100);
percentage.text = nPercent+"%";
nNumber = Math.round(_totalframes*(nPercent/100));
_root.onenterframe = function(){
if (nLoad == nTotal) {
gotoAndPlay("main", 1);
} else {
gotoAndStop(nNumber);
}
}
system
March 17, 2003, 11:07pm
8
no,
_root.onEnterFrame = function(){
nTotal = _root.getBytesTotal () / 1000;
nLoad = _root.getBytesLoaded () / 1000;
nPercent = Math.round ((nLoad / nTotal) * 100);
nRemain = nTotal - nLoad;
percentage = nPercent + "%";
nNumber = Math.round (_totalframes * (nPercent / 100));
_root.movieClip._alpha = nPercent;
if (nRemain <= 0 && nLoad != 0) {
gotoAndPlay ("main", 1);
}
};
and use a tween just give that MovieCLip the instance name “movieClip” and change its alpha. thats what i did with that file.
http://www.livetoskateboard.com/test/bleh2.fla
system
March 17, 2003, 11:50pm
9
right … i could just tween the symbol with action script … but i’d like to be able to put any animation in there that i want
=)
thanks very much … i’m going to go try it out
system
March 18, 2003, 12:02am
10
em … i’m a complete *******
i saved over my original file b/c i got the preloader working the way i want it to … but now the buttons don’t work
what happened to them? (i.e. load the site and try to click a button)
system
March 18, 2003, 12:14am
11
well i made it work again … i also changed the name from bleh to site.fla … http://www.aaronsleeper.com/site.fla
but i guess i can’t have a preloader.
i made the preloader work … but at the cost of my buttons in the next scene. i don’t see any conflicts but then again i probably missed something.
stupid scenes
i wish i could have a preloader