I am searching through my DisplayContainer for text fields to change them but i have a problem with changing the reference:
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";
}
}
The item.text throws:
1119: Access of possibly undefined property text through a reference with static type flash.display:DisplayObject.
How do i convert it so i can use it?
You need to type it as a
TextFieldbefore you can call aTextFieldmethod on it: