I have 3 questions regarding my migration from AS2 to AS3.
First, in AS2, I could generate variables on the fly. For
example, I could write:
var textHolder=new MovieClip
I believe that doing this in AS3 requires me to extend
MovieClip and to declare myVar in the sub-class. Is this correct?
Second, in the code below, a text field (i.e. tf) is a child
of a Movie Clip (i.e. textHolder), however, I don't seem to be able
to control the text field though the chain textHolder.tf For
example, if I try the following:
trace("name="+e.target.tf.name), I get the error message: A
term is undefined and has no properties.
Is there another way to do this.
Third, I notice that the following line is very important:
Removing it allows me to use the following trace statement:
What is happening here?
No, the MovieClip class is still dynamic so you can add
properties. If you extend MovieClip but you dont declare your
subclass dynamic, then you cannot add properties.
To access a display list you need to use getChildByName or
getChildAt. If you would add an instance name on your tf you can
retrieve that tf using getChildByName(), see attached snippet
(assuming you assign an instance name in the loop using tf.name =
You need to read up on the target and currentTarget
properties of events.