1120:未定义的属性的访问 [英] 1120: Access of undefined property
本文介绍了1120:未定义的属性的访问的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
为什么我收到一个 1120:未定义的属性arrMonth的访问
在该行误差 arrMonth.push
以及如何纠正呢?
< FX:脚本>
<![CDATA [
[可绑定]
公共变种arrMonth:阵列=新的Array();
arrMonth.push({标签:一月});
]]≥
< / FX:脚本>
解决方案
这其中的原因错误是你的逻辑(推
语句)是不是一种方法里面,因此,它被认为是在类水平(即静态的),而不是在实例级别。
这意味着有两种方法来解决这个问题
1 /使静态变量太多(我怀疑这是不是你想要的,但它会修正这个错误)。
< FX:脚本>
<![CDATA [
公共静态无功arrMonth:阵列=新的Array();
arrMonth.push({标签:一月});
]]≥
< / FX:脚本>
2 /把逻辑中的方法,例如:
< FX:脚本>
<![CDATA [
[可绑定]
公共变种arrMonth:阵列=新的Array();
覆盖保护功能initializationComplete():无效{
super.initializationComplete();
arrMonth.push({标签:一月});
}
]]≥
< / FX:脚本>
Why I'm getting a 1120: Access of undefined property arrMonth.
error at the line arrMonth.push
and how to correct it?
<fx:Script>
<![CDATA[
[Bindable]
public var arrMonth:Array = new Array();
arrMonth.push({label: "January"});
]]>
</fx:Script>
解决方案
The reason for that error is that your logic (the push
statement) is not inside a method, hence it is considered to be at class level (i.e. static) instead of at the instance level.
Which means there are two ways to fix it:
1/ Make the variable static too (I suspect this is not what you want, but it will fix the error).
<fx:Script>
<![CDATA[
public static var arrMonth:Array = new Array();
arrMonth.push({label: "January"});
]]>
</fx:Script>
2/ Put the logic in a method, for instance:
<fx:Script>
<![CDATA[
[Bindable]
public var arrMonth:Array = new Array();
override protected function initializationComplete():void {
super.initializationComplete();
arrMonth.push({label: "January"});
}
]]>
</fx:Script>
这篇关于1120:未定义的属性的访问的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文