Unable to retrieive instance name (sometimes)
Hello All,
I will try to state this simply. If required I can post my code. I have created a class that extends the MovieClip.
It is basically a retangular shape, with a color and a label that can be set via the "properties" concept.
The label.text property is public.
I create a "new" object of this item (more or less a button) depending on reading an xml file.
If the file has 3 names (titles like "Lesson 1", Lesson 2" etc). I create a new "button" for each name in the xml file.
so I can get 3 instances of the object on the stage. Which I get. I create each new object like this:
var link:linkBase;
var menu:linkBase;
I use a for loop to read the xml data, and create the instances:
for ....
menu = new linkBase();
// i try to give it an instance name like the
menu.name = xmlList.name // name = "Week1", "Week2", "Week3", etc
i push the menu object into an array like this: nav_button.push(menu), in the for loop.
I can draw the three objects on the stage.
I have a stage listener that will trace the target name if I click on the instance. I get "null" if I click off the button.
My problem is that I get the target name for only the second and third instances, and not the first.
If I comment out the menu.name line, and click each instance on the stage, I get "instance9", instance12, instance15. So I know there are three
objects there.
I can do something like this to get a name on the first instance: nav_button[0].name = xmlList.week, or hard code a string like "Week1".
But I want to be able to do this in a loop of some sort. I am trying to create a user friendly name for each instance, so I know
what I am clicking on, and take action depending on the name "week1", "week2" etc.
Any ideas on what I am missing in terms of naming a instance on the stage?
Thanks
eholz1