Instance Name vs. Symbol Name

There is a very common mistake among Flash beginners to confuse the instance name with the Symbol name. In this tutorial, I'm going to describe both of the names briefly and show where you may encounter them. Also, I'm going to give you a few tips on naming your symbols.

Symbol name

Symbol name is a name that we give to our soon-to-be symbols. Select anything on the stage, press F8 and, in the dialog box that pops up, specify the Symbol name.



The most important thing to remember is that this name is used everywhere but Actionscript. For example, if I create a Movieclip and name it head_mc, and then give it an instance name of head:

I will see head_mc, and not head, in the Library (Ctrl + L)

I will be able to swap head_mc, and not head, to some other symbol

I will be able to apply filters to head_mc, and not head.

And so on,

However, if I write a code like the one below on the first frame of the Timeline ...

_root.head_mc._x = 200


... my symbol won't even budge. That's bacause instead of head_mc, there should be head - the instance name of our symbol.

How to name your symbols

When naming your symbols people often tend to:

a) type just anything, like dasdsadsadsaadsdsasaddfadgggs. I used to do that too.

[ don't name your symbols like this! ]


b) type things as short as "head", for the name of the head of their newly-created one-eyed, limp American pit-bull terrier.

These two habits are definitely bad. They both lead to confusion later on.

I'm sure some of you might be wondering why the heck naming your symbols as shown in the second example is wrong. Let me explain:

It's a good habit to name your symols in a little more unique way. For example, in the above-mentioned example of the dog, it would be good to at least name it dog_head_mc. It's some sort of time investment; later on, you'll find yourself exporting symbols from one project to another and, as you might expect, there is no way for two symbols named head to be in the same project.



[ a library conflict caused by two symbols with the same name ]


Remember that adding a few more characters is just a second, while managing poorly-named symbols can slow you down quite a lot!

The instance name


The instance name is, well, some kind of name that we assign to Buttons and Movieclips to address them with Actionscript. You can find the field in which you type the instance name by selecting a button or a Movieclip and opening your properties window (Ctrl + F4) in whose bottom-left corner it should be situated.

 

 

How to use it exactly? Let me show you several examples:

sky._alpha = 30;
sky._x = 400;
sky._y = 100;

In this Actionscript code, I'm changing the alpha and the x and y coordinates of a symbol with an instance name of sky. However, keep in mind that this is how I would address sky symbol if we worked on the main Timeline (!). If the code was, say, inside the symbol, the code would be as follows:

_root.sky._alpha = 30;
_root.sky._x = 400;
_root.sky._y = 100

You can read more about _root and _parent in this tutorial.

I hope this tutorial helped you dissolve confusion (if you had any) around that subject. Please, see other tutorials.

Average: 3.7 (11 votes)