So I want to extend the dictionary class. Everything works so far except that in some of my methods that need to reference the dictionary's content I make a call like:
所以我想扩展字典类。到目前为止一切都有效,除了在我的一些需要引用字典内容的方法中,我打电话如下:
this[ key ]
It doesn't like that. It just tells me that there's no property 'key'. Is there a way to way to access the data within this class?
它不喜欢那样。它告诉我,没有属性'关键'。有没有办法访问这个类中的数据?
Also, I'm using an integer for the key.
另外,我正在使用一个整数作为密钥。
Edit: I've found that the same behavior happens when you extend Array.
编辑:我发现扩展Array时会发生相同的行为。
var myArray : Array = new Array();
trace( myArray[ 0 ] );
var myArrayExtender : ArrayExtender = new ArrayExtender();
trace( myArrayExtender[ 0 ] );
Where in this case, myArray returns "undefined" and myArrayExtender throws error 1069. ArrayExtender is an empty class that extends Array and calls super() in the constructor.
在这种情况下,myArray返回“undefined”,myArrayExtender抛出错误1069. ArrayExtender是一个空类,它扩展Array并在构造函数中调用super()。
1 个解决方案
#1
from what you say, i am quite sure you did not declare ArrayExtender
as dynamic
in ECMAscript array access and property access are semantically equivalent ... #1069 happens, if you access an undefined property, on a sealed class, because thes do not allow adding properties at runtime ...
从你的说法,我很确定你没有声明ArrayExtender在ECMAscript数组中是动态访问和属性访问在语义上是等价的......如果你在密封的类*问一个未定义的属性,会发生#1069,因为它们不允许在运行时添加属性...
same thing for the Dictionary
...
同样的字典...
greetz
back2dos
#1
from what you say, i am quite sure you did not declare ArrayExtender
as dynamic
in ECMAscript array access and property access are semantically equivalent ... #1069 happens, if you access an undefined property, on a sealed class, because thes do not allow adding properties at runtime ...
从你的说法,我很确定你没有声明ArrayExtender在ECMAscript数组中是动态访问和属性访问在语义上是等价的......如果你在密封的类*问一个未定义的属性,会发生#1069,因为它们不允许在运行时添加属性...
same thing for the Dictionary
...
同样的字典...
greetz
back2dos