1

I'm trying to control a movieclip which is located in another movieclip, the problem is that the child movieclip has a dynamic instance name, please take a look for this example:

var myvar = "2";

mc_1.mc_2.y = 0; // that's ok

but if I try:

mc_1.this["mc_"+myvar"].y = 0;    

Syntax error: expecting identifier before this."`

I try:

this["mc_1.mc_"+myvar"].y = 0;

Error #1010: A term is undefined and has no properties.

and when I try that:

MovieClip("mc_1.mc_"+myvar").y = 0;     

Error #1034: Type Coercion failed: cannot convert "mc_1.mc_2" to flash.display.MovieClip.

one more try:

mc_1.MovieClip("mc_"+myvar").y = 0; 

Error #1006: MovieClip is not a function.

akmozo
  • 9,829
  • 3
  • 28
  • 44
Abaq
  • 13
  • 2

1 Answers1

0

You can simply do :

var myvar:String = '2';

mc_1['mc_' + myvar].y = 0; 

Hope that can help.

akmozo
  • 9,829
  • 3
  • 28
  • 44