Percent reader follows preload bar

Hi –

Have a preloader bar that stretches from left to right until it fills a gauge in the background-- standard stuff.

Also have a KB numerical reader that calculates from 0 to 100%-- again standard stuff.

I would really like the numerical reader to follow the right hand side of the preloader bar as it grows from left to right. Can’t really figure it out.

Here is the preloader code-- pretty standard-- please, someone, help me make the KB reader move with the load bar width.

Thanks in advance, sure it must be simple, but confused as heck.

this.stop();
// Stop movie and do the preloader.
myInterval = setInterval(preloader, 1);
function preloader() {
if (getBytesLoaded()>=getBytesTotal()) {
_parent.gotoAndPlay(3);
clearInterval(myInterval);
}
loadbar._xscale = (getBytesLoaded()/getBytesTotal())*100;
loadtext.text=Math.round(getBytesLoaded()/getBytesTotal()*100)+"%";
}

loadbar._xscale = (getBytesLoaded()/getBytesTotal())*100;
loadtext.text = Math.round(getBytesLoaded()/getBytesTotal()*100)+“%”;
loadtext._x = loadbar._x+loadbar._width;

you may need to add/subtract something to it.

thank you very much!!! worked like a charm!

–Cheers!

welcome

I’m looking to do something like this as well but my AS is a little different. I was trying to apply this code to mine but doesn’t seem to work.

On my loader bar:

onClipEvent(load) {
	total = _parent.getBytesTotal()/1000;
}
onClipEvent(enterFrame) {
	current=_parent.getBytesLoaded()/1000;
	if (total == current&&current > 5) { 
		_parent.gotoAndPlay(2);
	} 
	else {
		_parent.loadAmount = Math.round (current/total*32);
		this._xscale = Math.round (current/total*100);
	}
}

And my text box has a variable name of loadAmount. What do I need to modify in your code to apply it to my own? Thanks in advance.

give the textfield an instance name of myText

_parent.loadAmount = Math.round(current/total32);
this._xscale = Math.round(current/total
100);
_parent.myText._x = this._x+this._width;

Thanks very much :slight_smile: You rule.

can you guys post a fla. because i can’t seem to get it going.

Gupps,
Here is the fla. Hope this helps, if you have any questions about it post them here because I can’t check my email from work.

here

hi beneath the sky,
the link is dead.

Gupps,
Sorry about that, I was in a hurry when I posted it. I will fix it when I get home later this afternoon.

edit: link is fixed

thanks beneath the sky. I’ll take a look at that right now