PDA

View Full Version : [fmx] preloader: what am I doing wrong?



bleutuna
June 9th, 2003, 01:40 AM
the file: http://www.mariomilitia.com/sg_main_movie_preloader.fla



Though it *should* go to the second frame, it doesn't, and I can't figure out why. It just sits on the preloader, refusing to go forward.

The script for the preloader is on the MASK, but it's also written below:

onClipEvent (enterFrame) {
bytesLoaded = _root.getBytesLoaded();
totalSize = _root.getBytesTotal();
_root.percentLoaded = (bytesLoaded/totalSize)*100
_yscale = _root.percentLoaded

if (bytesLoaded == totalSize) {
this.gotoAndStop(2);
}
}


Anyone have any ideas?



:pope:

Raydred
June 9th, 2003, 01:51 AM
try this...


_root.percentLoaded = Math.Floor((bytesLoaded/totalSize)*100);


the Math.Floor rounds down to the nearest whole number, it was probaly returning something like 3.454 when you wanted 3;

bleutuna
June 9th, 2003, 10:17 AM
Cool, figured it out:

Needed to change the _this.gotoAndStop(2); to a _root.gotoAndStop(2); - and it worked great :)

http://www.mariomilitia.com//servicegroup/index.html

:pope:

dogday
June 9th, 2003, 10:23 AM
Take a look at the actions layer. You have an stop in frame 1.

If you control your movie with the preloader .....

Remove the stop from frame one.

Keith130
June 9th, 2003, 12:33 PM
I think that it is better to have a preload function and use setInterval to update it continuesly. The script I use in my .swf files is below.


stop();
preload = setInterval(loader,10);
function loader(){
if(getBytesLoaded() >= getBytesTotal()){
stopAllSounds();
nextScene();
}
txtPercent = Math.round(getBytesLoaded() / getBytesTotal() * 100) + "%";
}