将数组中的字符串组合到实例路径

时间:2015-02-09 13:43:07

标签: actionscript-3 flash

我要做的是将一个静态实例名称('antwoordBox1',其中包含几个带有实例名称的动画片段)与一个动态选择的对象组合在一起(DefVragenArray [0] [1] [1] )。但是当我尝试使用新的实例路径时,我收到以下错误。

ReferenceError:错误#1069:在String上找不到属性alpha且没有默认值。

var newString:Object = 'antwoordBox1.' + DefVragenArray[0][1][1];|

// set the alpha of the selected instance to '100'
newString.alpha = 100;

不确定我在这里做错了什么。有帮助吗?谢谢!

1 个答案:

答案 0 :(得分:0)

根据您的评论,要获取MovieClip的名称,这是您的vragen数组的单元格的第2个元素,您应该执行:vragen[i][1],因为您的Array 1}}是:

var vragen:Array = [
    ['foto.url', 'antwoord_1', '1', 'fout'],    // 0 : [0, 1, 2, 3]
    ['foto2.url', 'antwoord_2', '2', 'fout'],
    ['foto3.url', 'antwoord_3', '3', 'fout'],
    ['foto4.url', 'antwoord_1', '4', 'fout']
];

因此,要访问antwoord_1内的antwoordBox1 MovieClip,您可以执行以下操作:

var newString:Object = antwoordBox1[vragen[0][1]];

    // the value of alpha is between 0 and 1, 0 is 0% and 1 is 100%
    newString.alpha = 1;

希望可以提供帮助。