Hi!
Since yesterday morning I´m googleing searching for an answer and I´m not able to find it, here is my problem:
I have an Arrays that contains the names of MovieClips:
var MyMCs:Array = ["A","B","C","D","E"];
The actual MovieClips names are “MC_A”, “MC_B”, etc…, I use this method so I reuse the same Array for multiple tasks, I simply add what ever it’s needed to the name to match the task at hand. On this case I add “MC_”.
Then I have multiple Arrays, with the same names of the values of MyMCs.
The values of each these Arrays are the names of buttons that are inside the movieclips of MyMCs:
var A:Array = ["RR","TT"];
var B:Array = ["YY","UU"];
etc...
I could add a listener to a button this way:
MC_A.YY.addEventListener(MouseEvent.CLICK, DoSomething)
My problem is that i want it to be done dynamically, using the Arrays values in a loop to add Listeners to the all buttons. The loop system is not a problem for me… my real problem is in the dynamic attribution itself.
Here is what I have:
//'i' and 'j' have previously been created
for(i=0; i<MyMCs.length; i++){
for(j=0; j<this[MyMCs*].length; j++){
root["MC_"+MyMCs*].this[MyMCs*][j].addEventListener(MouseEvent.CLICK, DoSomething);
}
}
Explaning the code:
root[“MC_”+MyMCs]* values are “MC_A”, “MC_B”, etc…
this[MyMCs][j]* values are “RR”, “TT”, “YY”, “UU”, etc…
I know that this is correct since I tried them separately and I can trace the proper values.
I know that my problem is in the “this” since I get an error message stating:
1084: Syntax error: expecting identifier before this.
I suppose it should state something else… I tryed with “root”, “parent”, “child”, “MovieClip”… with no luck…
Can anyone give me a hand?