Preloader error - what could this be?

I’ve got a preloader with the script below but I keep getting a Sytax error with it. It seems to work fine. Don’t really know because I don’t have a lot of information on the site just yet. Here is the error…

Error Symbol=Bar, layer=fill, frame=1:Line 10: Syntax error.
_parent.txt = percent add “%”;

Here is the code I’m using.

onClipEvent (load) {
	_root.stop();
}
onClipEvent (enterFrame) {
	var totalk = _root.getBytesTotal()/1024;
	var loadedk = _root.getBytesLoaded()/1024;
	var percent = Math.round((loadedk/totalk)*100);

	if (percent<100) {
		_parent.txt = percent add "%";
		_xscale = percent;
	} else {
		_root.play();
	}
}

Any ideas?

using _parent just tells flash to go out one level from where the code is written and look for the thing after _parent, which in your case is “txt”. Do you have a movieclip called txt? Also, I’m not sure what “percent add” means?

Thanks lunatic,
There is a dynamic text box named “txt”. I just found this code and thought I would try it out. If I need to use something else I will. Just wondering why it wasn’t working.

Trying to learn AS. But can’t figure some things out.

Thanks again!

Hello Scott,

follow this tutorial… its very simple.

but don’t just follow it… also read what it means each line… then you will be able to modify it as you wish.

http://www.kirupa.com/developer/mx/percentagepreloader.htm

it worked great for me!

cheers!

:nerd:

hey thanks lolomedia. I’ll check it out.