Substitute to _root in ActionScript 3 (AS3)

ActionScript 3.0 is the language used in a range of products developed by Adobe, this programming language is used in Flash, Flex and AIR. Anybody having knowledge of C,C++ or Java can easily start coding in ActionScript 3.0 which is popularly known as AS3. AS3 is more powerful than ActionScript 2 and there are many reasons to switch between AS2 to AS3. The main reason is that AS3 is a core language, you can work easily with Flash, Flex and AIR runtime when you become familiar with this programming language and also it has improved Flash Player API that provides increased control of low-level objects. You can even develop an Android application using ActionScript 3.0 with AIR runtime.

 Also read:

What happened to _root in AS3?

You might feel weird when you code for the first time in ActionScript 3 but you will be soon become familiar with it. Action script 3 is compiled in a totally different virtual machine (AVM2) which can execute the code 10 times faster comparing to AS2. Action Script 3 is strict when compared to Action Script 2 which is complete OOP language. There are many things which are either changed or updated in AS3. _root is such a function which is modified in AS3.

We find many people who search for equivalent to _root in AS3 in Google, Bing and many other search engines. Here is the replacement for _root in Action Script 3. Many developers have confusions using  _root in AS3 and here is the solution for this issue.

How to use _root in AS3?

Using _root in actionscript 3 is easy compared to actionscript 2, _root is used to access the root of the current level in AS2 but In ActionScript 3.0 _root is replaced with MovieClip(root).MOVIECLIPNAME. So if you want to access a movie clip called apple from another movie clip in AS3 then you have to code something like this-


In AS2 the code was like-;

MovieClip(root) is the prefix we need to add before the movie clip name to get the root of respective movie clip. many people say that _root has been removed from action script 3 but it is not removed but replaced with other keyword. Adobe has made this change to make actionscript 3 a complete object oriented programming language. Not only this but there are many other changes it has made to action script. Every elements in action script 3 are an objects therefore you must define a class to import new object on the stage. You can learn more about this stuff and also get many samples on Adobe Actionscript Tutor website.

Substitute to _root in ActionScript 3 (AS3) 1
Hi, this is +Shrinivas, from Belgaum. I'm a part of the Techgyo community.

Grab your lifetime license to AI Image Generator. Hostinger Hosting