From AS2 to AS3 what is the equvalent of _root?

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?

Need Your Help

EL expression in js function on jsp page

javascript jsp el

Can I use el expressions in js functions that are on jsp page?

About UNIX Resources Network

Original, collect and organize Developers related documents, information and materials, contains jQuery, Html, CSS, MySQL, .NET, ASP.NET, SQL, objective-c, iPhone, Ruby on Rails, C, SQL Server, Ruby, Arrays, Regex, ASP.NET MVC, WPF, XML, Ajax, DataBase, and so on.