# This is killing me...preloader!

**URL:** <https://forum.kirupa.com/t/this-is-killing-me-preloader/35216>\
**Category:** flash\
**Created:** [November 11, 2003, 6:58pm UTC](https://forum.kirupa.com/t/this-is-killing-me-preloader/35216 "2003-11-11T18:58:41Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![rave\_t](https://avatars.discourse-cdn.com/v4/letter/r/58956e/32.png) [@rave\_t](https://forum.kirupa.com/u/rave_t)\
**Post date:** [November 11, 2003, 6:58pm UTC](https://forum.kirupa.com/t/this-is-killing-me-preloader/35216/1 "2003-11-11T18:58:41Z")

</div>

This is my code in a movieclip which is loaded on the main timeline and the duplicated.

Its task is to load an image and i want to show the loading process.

temp is a textfield which should show the loading progress.  
but it says 0% then "infinity"and finally 100% but nothing in between.

What is the problem???

* * *

this.createEmptyMovieClip(“preloader”, 1000);  
this.createEmptyMovieClip(“container”, 1001);  
container.loadMovie(“images/” add imagename);  
container.\_visible = false;  
preloader.onEnterFrame = function() {  
var l = container.getBytesLoaded();  
var t = container.getBytesTotal();  
var getPercent = l/t;  
temp = Math.round(getPercent\*100)+"%";

```
if (l&gt;0 && l&gt;=t) {
	container._visible = 1;
	delete this.onEnterFrame;
}

```

};

---

<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 11, 2003, 8:43pm UTC](https://forum.kirupa.com/t/this-is-killing-me-preloader/35216/2 "2003-11-11T20:43:16Z")

</div>

Well, that code is kind of messy and I’m not sure what the problem is. Let’s keep it simple huh? Delete your current movieclip. I’ll help you make a accurate, simple, smooth and effective one. :)[list=1][_]Put a stop action on frame 1 of the main timeline.[_]Make a new movieclip.[_]Insert a dynamic textbox and give it the variable **percentage**.[_]Go back to the main timeline, select the movieclip, and insert these actions to the panel:

```auto
onClipEvent (enterFrame) {
	loading = _parent.getBytesLoaded();
	total = _parent.getBytesTotal();
	percent -= (percent-((loading/total)*100))*.25;
	per = int(percent);
	percentage = "loaded: " + per + "%";
	if (percent>99) {
		_root.gotoAndStop(3);
	}
}

```

[/list] **[u]Explanation:**[/u][list][_]onClipEvent (enterFrame) { is when the movieclip shows up.[_]The 2nd and 3rd line determine how much bytes and how much loaded so far.[_]The 4th line divides loaded by total, turns it into a number relying on percents.[_]The 5th line turns the number so far into a integer number for all of us to understand.[_]The 6th line shows what will be in the variable we created along with the “%” symbol.[_]The 7th line makes it so that if the percent is greater than 99, gotoAndStop at the 3rd keyframe.[/list]- Hope I helped. :beam:
