[fmx] preloader: what am I doing wrong?

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:

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;

Cool, figured it out:

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

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

:pope:

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.

I think that it is better to have a preload function and use [AS]setInterval[/AS] to update it continuesly. The script I use in my .swf files is below.

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