我正在通过我的 DisplayContainer 搜索文本字段以更改它们,但我在更改参考时遇到了问题:
for (var i:uint = 0, n:uint = rootContainer.numChildren; i < n; ++i) {
var item:DisplayObject = rootContainer.getChildAt(i);
if (item is DisplayObjectContainer) {
updateFields(DisplayObjectContainer(item));
} else if (item is TextField) {
item.text = "hej";
}
}
item.text 抛出:
1119: Access of possibly undefined property text through a reference with static type flash.display:DisplayObject.
我如何转换它以便我可以使用它?