Hi, I am instantiating several items and storing them as Dynamic: they are different kinds of “TextField”, that can be extensions of TextField class itself or of MovieClips containing a TextField. All of these classes have a “text” editable property: in TextField extensions it is the default property, but in the extended/nested classes it can be a setter to indirectly edit text property of the contained TextField.
Now the problem is that when I have to set the text property/setter of these instances (that I remind are stored as Dynamic) Haxe does not know how to behave, and if I do
anInstance.text = "DOG";
it doesn’t update the item on screen, maybe because it doesn’t know what to do with the “text” property of a Dynamic: I have to cast it before.
How can I store these items as Dynamic and cast them to the correct class right before using their properties?
Using pseudo-code I could imagine something like this:
tfVariants = Array<Dynamic> = new Array<Dynamic>();
tfVariants.push(new CakeTextField());
cast(tfVariants[0], tfVariants[0].getMeTheRealClassType).text = "DOG";
Thanks
P.S.: it is funny to notice that if I trace the instance it shows the “[real classType name]”, but the item behaves as a Dynamic item.
If I cast it and trace it it shows the same “[real classype name]” as before, but the item behaves as the set classType.