ReferenceError:错误#1069:属性box_mc_0 [英] ReferenceError: Error #1069: Property box_mc_0
问题描述
我试图用循环来隐藏舞台上的影片剪辑,但是当我发布它的时候,我得到了下面的错误(这只是一个概念的例子。)
var q;
for(q = 0; q <= 3; q ++){
stage [box_mc_+ q] .visible = false;
错误讯息:
$ b
ReferenceError:Error#1069:属性
box_mc_0
$ bflash.display.Stage
,并且没有默认值。在
test_fla :: MainTimeline / frame1()
< a href =https://i.stack.imgur.com/wq1nu.jpg =nofollow noreferrer>
任何帮助,将不胜感激。
你只需要使用 this code>关键字而不是
阶段
变量:
var q;
for(q = 1; q <= 3; q ++){
this [box_mc_+ q] .visible = false;
$ b $ p
$ b 简单的原因是对象是 MainTimeline
对象, this
关键字在该上下文中引用的对象,它们不是 stage
。
如果您有兴趣了解更多关于差异的细节,您可以找到有用的信息这里。
I'm trying to hide movie clips from the stage using a loop, but I'm getting the following error when I publish it (this is just an example of the concept.)
var q;
for (q = 0; q <= 3; q++) {
stage["box_mc_" + q].visible = false;
}
The Error message:
ReferenceError: Error #1069: Property box_mc_0
not found on
flash.display.Stage
and there is no default value. at
test_fla::MainTimeline/frame1()
Any help would be appreciated.
解决方案 You simply need to use the this
keyword instead of the stage
variable:
var q;
for (q = 1; q <= 3; q++) {
this["box_mc_" + q].visible = false;
}
The simple reason being is that the objects are the children of a MainTimeline
object, to which the this
keyword would refer to in that context, and they are not the direct children of the stage
.
If you're interested for more details on the difference, you may find useful information here.
这篇关于ReferenceError:错误#1069:属性box_mc_0的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!