Bar Preload Help

Hey, I followed through the preloading with bar tutorial offered on kirupa, the bar part worked fine, but for some reason, the % part didn’t. Ahmed gave me a different code, but doesn’t seem to work either, here’s his code:

onEnterFrame = function () {
bytes_loaded = Math.round(this.getBytesLoaded());
bytes_total = Math.round(this.getBytesTotal());
getPercent = bytes_loaded/bytes_total;
this.loadBar._width = getPercent251;
loadText = Math.round(getPercent
if (bytes_loaded == bytes_total) {
delete this.onEnterFrame;

I followed everything on the kirupa tutorial, and this is the only change. I need this please.=)

Make sure you have the VAR name of the textbox set to “loadText” (no quotes) and not the INSTANCE name. there is a difference, and they are both in properties panel.

OMG! that’s what ahmed was tryiing to tell me…then what is the instance name?

You don’t need to give it an instance name if you are using a var name.

I can’t really think straight right now to give a clear description of the difference between var name and instance name, but basically var name only allows you to edit the text of a textbox, but instance name allows you to target the textbox as an object and edit the textboxs’ properties dynamically through AS.

so instances are more of an object orented…and var has more of an AS relation?

It’s kind of similar the way textfields and variables work in Visual Basic :slight_smile:

No, just basically the only thing the var name does is allows you to dynamically add text to the textbox and nothing else.

But if you use an instance name you are able to target the textbox and edit its properties through AS. Including TextFormat, restricting characters, enabling HTML text, etc, etc. And you can also use event handlers such as onChanged, or onSetFocus, and onKillFocus, etc, etc.

so instances are more physical property…not actual text

Well you can edit text as well.

Example of instance name text-

myTextBoxInstanceName.text = “asdf”

Example of var name text-

myTextBoxVarName = “asdf”

Think of it like changing the value of a variable. Instance name actually targets the textbox, but var name targets it like a variable.

Sorry if I make no sense, my head is kind of (well really) hazy tonight… soooo tiiired.

so it’s more specific