I'm trying to learn Actionscript 2 or 3, with AS2 I eventually figured by trial and error that I could get any named instance and modify it using a string with its name using
var theinstance = "titletext"; // actually exctracted from an array
_root[theinstance].htmlText = "New text with <b>HTML!</b>";
but when trying to convert the code to AS3 _root
doesn't exist anymore. According to the migration doc it is somehow replaced by flash.display.DisplayObject.stage
but apparently this is not how to do it:
flash.display.DisplayObject.stage[theinstance].htmlText = "New text with <b>HTML!</b>";
and neither is this:
flash.display.DisplayObject.stage.getChildByName(theinstance).htmlText = "New text with <b>HTML!</b>";
How do I get a child by name in actionscript 3?
Just use either "root" (no underscore) or "stage" depending on exactly what you want to do.
However - Why not just store a reference to the textField in the array instead of a string?