This is killing me...preloader!

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>0 && l>=t) {
	container._visible = 1;
	delete this.onEnterFrame;
}

};

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:

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: