# \[fmx\] preloader: what am I doing wrong?

**URL:** https://forum.kirupa.com/t/fmx-preloader-what-am-i-doing-wrong/22810
**Category:** flash
**Created:** [June 9, 2003, 5:40am UTC](https://forum.kirupa.com/t/fmx-preloader-what-am-i-doing-wrong/22810 "2003-06-09T05:40:05Z")
**Posts on this page:** 5
**Page:** 1

<div class="post-metadata">

### Author: ![bleutuna](https://avatars.discourse-cdn.com/v4/letter/b/eada6e/32.png) [@bleutuna](https://forum.kirupa.com/u/bleutuna)
#### Post date: [June 9, 2003, 5:40am UTC](https://forum.kirupa.com/t/fmx-preloader-what-am-i-doing-wrong/22810/1 "2003-06-09T05:40:05Z")

</div>

**the file:** [http://www.mariomilitia.com/sg\_main\_movie\_preloader.fla](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:

---

<div class="post-metadata">

### Author: ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)
#### Post date: [June 9, 2003, 5:51am UTC](https://forum.kirupa.com/t/fmx-preloader-what-am-i-doing-wrong/22810/2 "2003-06-09T05:51:59Z")

</div>

try this…

```php

_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;

---

<div class="post-metadata">

### Author: ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)
#### Post date: [June 9, 2003, 2:17pm UTC](https://forum.kirupa.com/t/fmx-preloader-what-am-i-doing-wrong/22810/3 "2003-06-09T14:17:04Z")

</div>

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](http://www.mariomilitia.com//servicegroup/index.html)

:pope:

---

<div class="post-metadata">

### Author: ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)
#### Post date: [June 9, 2003, 2:23pm UTC](https://forum.kirupa.com/t/fmx-preloader-what-am-i-doing-wrong/22810/4 "2003-06-09T14:23:50Z")

</div>

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.

---

<div class="post-metadata">

### Author: ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)
#### Post date: [June 9, 2003, 4:33pm UTC](https://forum.kirupa.com/t/fmx-preloader-what-am-i-doing-wrong/22810/5 "2003-06-09T16:33:35Z")

</div>

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]
