PDA

View Full Version : Variable names vs. instance names?


Resplendent Elk
07-26-2002, 01:11 PM
Whatīs the difference between variable names and instance names for text fields? The Flash MX help file and manual just says something like "the Var is the Variable Name", which isnīt very helpful.

The funny thing is that Iīve never had to use variable names until now. Iīm trying to set focus to a text field with Selection.setFocus("notesfield") and then select everything in the text field with Selection.setSelection(0, length), but I canīt get it to work. Itīs probably just a stupid n00b error, but Iīll probably be able to solve it when I understand the difference between variable and instance names.

Thanks in advance.

Tankshell
07-26-2002, 02:44 PM
Variable name refers to the value of the text field...ie what text is currently stored in the field.

Instance name refers to the text field object, its properties (width, height etc).

Simple.

Ricod
07-26-2002, 02:50 PM
A variable name is the name of a variable. Something that's dynamic, and likely to change. An instance name is the name of a specific 'copy' of a library object.

Let's say u have a mc which is called 'textFieldMc' in the library. This is the symbol name.

Now, u placed this mc 2 times on the main timeline. The first is labeled 'myFirstTextField' and the second, conveniently, 'mySecondTextField'. These are instance names.

Since both are instances of the same symbol, the both have the same variablename. Let's say 'TextField1'. This is the variable name.

It doesn't matter they both have the same, since they are both in different instances. Being labeled differently, the path to the variables are different. The first has : _root.myFirstTextField.TextField1;

and the 2nd :

_root.mySecondTextField.TextField1;

dpvtank
07-26-2002, 07:05 PM
read the tut's by Jesse Stratford here....they are helpfull.