# Preloader actionscript

**URL:** https://forum.kirupa.com/t/preloader-actionscript/7374
**Category:** Uncategorized
**Created:** [October 29, 2002, 6:10pm UTC](https://forum.kirupa.com/t/preloader-actionscript/7374 "2002-10-29T18:10:28Z")
**Posts on this page:** 4
**Page:** 1

<div class="post-metadata">

### Author: ![sk8erboi\_Q8](https://avatars.discourse-cdn.com/v4/letter/s/91b2a8/32.png) [@sk8erboi\_Q8](https://forum.kirupa.com/u/sk8erboi_Q8)
#### Post date: [October 29, 2002, 6:10pm UTC](https://forum.kirupa.com/t/preloader-actionscript/7374/1 "2002-10-29T18:10:28Z")

</div>

i created an animaton in flash mx of a speedometer going from 0-100, i want it to become a preloader , so that KM/H represents the % complete…but i have trouble with the actionscripting part…can any one help me please…? 🙂 i’d be really grateful!

---

<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: [October 29, 2002, 6:15pm UTC](https://forum.kirupa.com/t/preloader-actionscript/7374/2 "2002-10-29T18:15:38Z")

</div>

Yeah! I’d love to see this too!! 🙂

---

<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: [October 29, 2002, 6:20pm UTC](https://forum.kirupa.com/t/preloader-actionscript/7374/3 "2002-10-29T18:20:58Z")

</div>

First you have to make your pointer bar thingamagig its own movie clip with the registration point at the far end that goes in the center of the speedometer.

Depending on the space for rotation…

Frame 1…

```auto
bytes_loaded = Math.round(_root.getBytesLoaded()/1000);
bytes_total = Math.round(_root.getBytesTotal()/1000);
_root.pointerBar._rotation = bytes_loaded/bytes_total*100;
if (bytes_loaded == bytes_total) {
	gotoAndPlay("Scene 2", 1);
	delete bytes_loaded;
	delete bytes_total;
}

```

Frame 2

```auto
gotoAndPlay(1);

```

Something along those lines, this is untested of course. As for the gotoAndPlay at Scene 2, I always put my preloader in the scene before my movie, I find it easier for me to edit my movie without having to go over the preloader. I am a strange one, you can change what it loads to whatever

---

<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: [November 15, 2002, 8:01pm UTC](https://forum.kirupa.com/t/preloader-actionscript/7374/4 "2002-11-15T20:01:38Z")

</div>

Or you could do this…I use this preloader quite often…

I designate the first two frames of my \_root time line to the preloader.

Frame 1:  
(ActionScript)  
var percent = Math.Ceil((\_root.getBytesLoaded() / \_root.getBytesTotal()) \* 100 );  
progressbar.gotoAndStop(percent);

Frame 2:  
(ActionScript)  
if (percent \< 100 ) {  
\_root.gotoAndPlay(1);  
}else{  
\_root.gotoAndPlay(3);  
}

Of course you’ll have your “progressbar” Movie Clip that tweens from frame 1 to 100.

Hope this helps out.

:cyclops:
