我如何定位动画片段的动态名称,它是另一个动画片段的 child
How can I target dynamic name of movieclip which is a child of another one
我正在尝试控制位于另一个动画片段中的动画片段,问题是 child 动画片段具有动态实例名称,请查看此示例:
var myvar = "2";
mc_1.mc_2.y = 0; // that's ok
但如果我尝试:
mc_1.this["mc_"+myvar"].y = 0;
Syntax error: expecting identifier before this."`
我试试:
this["mc_1.mc_"+myvar"].y = 0;
Error #1010: A term is undefined and has no properties.
当我尝试这样做时:
MovieClip("mc_1.mc_"+myvar").y = 0;
Error #1034: Type Coercion failed: cannot convert "mc_1.mc_2" to flash.display.MovieClip.
再试一次:
mc_1.MovieClip("mc_"+myvar").y = 0;
Error #1006: MovieClip is not a function.
你可以简单地做:
var myvar:String = '2';
mc_1['mc_' + myvar].y = 0;
希望能帮到你。
我正在尝试控制位于另一个动画片段中的动画片段,问题是 child 动画片段具有动态实例名称,请查看此示例:
var myvar = "2";
mc_1.mc_2.y = 0; // that's ok
但如果我尝试:
mc_1.this["mc_"+myvar"].y = 0;
Syntax error: expecting identifier before this."`
我试试:
this["mc_1.mc_"+myvar"].y = 0;
Error #1010: A term is undefined and has no properties.
当我尝试这样做时:
MovieClip("mc_1.mc_"+myvar").y = 0;
Error #1034: Type Coercion failed: cannot convert "mc_1.mc_2" to flash.display.MovieClip.
再试一次:
mc_1.MovieClip("mc_"+myvar").y = 0;
Error #1006: MovieClip is not a function.
你可以简单地做:
var myvar:String = '2';
mc_1['mc_' + myvar].y = 0;
希望能帮到你。