将数组中的字符串组合到实例路径
Combine strings from array to an instance path
我想做的是将静态实例名称('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;
不确定我做错了什么。有什么帮助吗?谢谢!
根据您的评论,要获取 MovieClip
的名称,这是 vragen
数组单元格的第二个元素,您应该这样做:vragen[i][1]
因为您的Array
是:
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']
];
因此,要访问 antwoordBox1
中的 antwoord_1
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;
希望能帮到你。
我想做的是将静态实例名称('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;
不确定我做错了什么。有什么帮助吗?谢谢!
根据您的评论,要获取 MovieClip
的名称,这是 vragen
数组单元格的第二个元素,您应该这样做:vragen[i][1]
因为您的Array
是:
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'] ];
因此,要访问 antwoordBox1
中的 antwoord_1
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;
希望能帮到你。