ReferenceError:错误#1069:在String上找不到属性可见,并且没有默认值

时间:2012-08-14 14:08:34

标签: actionscript-3 flash

function item_back_click(evt:Event):void {
     var back:MovieClip = MovieClip(evt.currentTarget);
     var req:URLRequest = new URLRequest(MovieClip(back.parent).data.@link);
     var listnumber = ("listbox" + MovieClip(back.parent).data.@link);
     trace(listnumber);
     if (listnumber.visible == false) listnumber.visible = true;
}

trace(listnumber);显示listbox1

if (listnumber.visible == false) listnumber.visible = true;

给出错误:

ReferenceError: Error #1069: Property visible not found on String and there is no default value.
    at listbox_fla::listbox_1/item_back_click()

为什么会这样?

这很有效:

if (listbox1.visible == false) listbox1.visible = true;

1 个答案:

答案 0 :(得分:1)

“listBox1”是一个字符串而不是一个变量。所以基本上你试图访问不存在的字符串的可见属性。

"listBox1".visible = true;  // error

尝试:

this[listnumber].visible = true;