I need help with some preloader actionscript

I am trying to do the flash mx pro 2004 bible’s tutorial of how to build a preloader and I ran into some trouble… heres the actionscript I enetered…
var 1Bytes = this.getBytesLoaded();
var TBytes = this.getBytesTotal();
var percentLoaded = Math.floor((1Bytes/tBytes)*100);
loader_mc.bar_mc._xscale = percentLoaded;
loader_mc.percent = percentLoaded + "% of " + Math.floor(tBytes/1024) + “K loaded.”;
if (1Bytes >= tBytes && tBytes > 0) {
if (count>12) {
gotoAndStop(“main”);
} else {
count++;
}
} else {
gotoAndPlay(“preload”);
}

when I go to publish this the following errors occur…
Error Scene=Scene 1, layer=actions, frame=3:Line 1: Identifier expected
var 1Bytes = this.getBytesLoaded();
Error Scene=Scene 1, layer=actions, frame=3:Line 3: ‘)’ expected
var percentLoaded = Math.floor((1Bytes/tBytes)*100);
Total ActionScript Errors: 2 Reported Errors: 2

Im a noob so this doesnt mean much to me yet, what should I do to make it work? thanks. -UA

The name of a variable/object/function/etc. may not start with a number (well, at least not by conventional means ;)). I think you’ve misread the book and it should be “l” (lowercase L) instead of “1”. :slight_smile:

var lBytes = this.getBytesLoaded();
var tBytes = this.getBytesTotal();
var percentLoaded = Math.floor((lBytes/tBytes)*100);
loader_mc.bar_mc._xscale = percentLoaded;
loader_mc.percent = percentLoaded+"% of "+Math.floor(tBytes/1024)+"K loaded.";
if (lBytes>=tBytes && tBytes>0) {
	if (count>12) {
		gotoAndStop("main");
	} else {
		count++;
	}
} else {
	gotoAndPlay("preload");
}

thanks, that was the problem, yet still it doesnt work. when I test the movie it just pauses on the first frame… the preloader doesnt do anything… raaaaaaaaaaa! this is frustrating… helP?

Was the variable “count” properly defined? Try this one:

if (!count) var count = 1;
var lBytes = this.getBytesLoaded();
var tBytes = this.getBytesTotal();
var percentLoaded = Math.floor((lBytes/tBytes)*100);
loader_mc.bar_mc._xscale = percentLoaded;
loader_mc.percent = percentLoaded+"% of "+Math.floor(tBytes/1024)+"K loaded.";
if (lBytes>=tBytes && tBytes>0) {
	if (count>12) {
		gotoAndStop("main");
	} else {
		count++;
	}
} else {
	gotoAndPlay("preload");
}

thanks man… it worked… if you wanna see what Im messing around with you can go to this link… www.unrefinedartists.com/trial.htm … I just started trying harder things in flash two days ago, the site that loads when you click the “enter” button isnt mine though, just a companies. thanks again mang. -UA

You’re welcome. :slight_smile:

that site isnt bad. One thing i would recommend is to edit the text so that it doesnt appear choppy and blurry.

turn off audio choice in intro and first page, and allow to skip intro, then it’d be pretty cool :slight_smile: