Hi there everyone… any help with this problem would be much appreciated. I am building a preloader that features an animated character (a movieclip named ‘dogLoad’). As the preloader progresses I would like the movieclip to be told to advance further along its timeline. I managed to get it to work once but deleted the code by mistake…
Here’s what I’ve written (the following doesn’t work…)
bytes_loaded = Math.round(this.getBytesLoaded());
bytes_total = Math.round(this.getBytesTotal());
getPercent = bytes_loaded/bytes_total;
this.loadText = Math.round(getPercent*100)+"%";
if (Math.round(getPercent*100) > 25) {
dogLoad.gotoAndPlay(2);
}else if (Math.round(getPercent*100) > 50) {
dogLoad.gotoAndPlay(9);
}else if (Math.round(getPercent*100)>75) {
dogLoad.gotoAndPlay(20);
}
if (bytes_loaded == bytes_total&&bytes_total!=0) {
this.gotoAndPlay(3);
}
Right off the bat I can see that you forgot the parenthesis around the if conditions. I’ve added them above for you to see.
I’ve changed it from tell target to the new dot syntax which 5.0 and above uses for object control. Telltarget has been depreciated. I’ve also added an && statement to the last “if”. The reason for this is that sometimes when a file FIRST starts to load, it’s total frames will register as 0, and obviously frames loaded registers as 0 before the movie has loaded anything. If that happens, then the last if statement will ring “true” and the root will gotoAndPlay(3) when you don’t want it to. Lastly I made your various if statements “if else” statements. Since you will never encounter a situation where it will be both 25% and 50% it might as well be “if else”. It saves on processor power that way.
I’m assuming at this point that this is on the main timeline, and that there is also a loop involved… but it looks like it should work fine.
If it still doesn’t work… write back and let me know… I’ll keep thinking on it.