Playback starts YouTube’s embedded player (privacy-enhanced mode).
How to Use Addchild in Action Script
ChannelInternet Services and Social Networks Tutorials from HowTechDescription from the creator
Don't forget to check out our site howtech.tv/ for more free how-to videos!
youtube.com/ithowtovids - our feed
facebook.com/howtechtv - join us on facebook
plus.google.com/103440382717658277879 - our group in Google+
ActionScript 3.0 uses a very powerful display list through which objects are displayed in flash. The display list can be applied only to objects that are visual, like shapes, text box and lines. Values and variable are non visual objects and cannot be used by display list. Display list uses two important functions; addChild() actionscript 3 and removeChild(). addChild() actionscript is used to display object to the screen and removeChild() to remove the object from the screen. Let's look into a simple example to add a circle shape and a text box.
Step 1: Open a new flash project
First, let's open a new flash project. ActionScript 3.0 should be the type of the file chosen.
Step 2: Create an object
Create an object myText of class TextField and instantiate the same. Add some text to myText. To make the objects visible in the stage, use the addChild() actionscript method as follows:
This text can be formatted, resized and repositioned. There are functions available for all the text manipulation.
Step 3: Creating a symbol
Previously in ActionScript 2.0, there were classes to create shapes instantly. This is removed in ActionScript 3.0. So to import the shapes, we should create them manually.
To start with, let's create a circle and convert it to a symbol. In the 'convert to symbol' window, choose the option 'Export for ActionScript' in the advanced settings and type in the class name as 'Circle'. This movie clip is now registered in the library. Delete of the circle from the stage area.
Step 4: New Circle
Similar to the class TextField, we have a class for the circle. To instantiate the class, let's type in the following code followed by the addChild() actionscript 3 function to display on to the stage:
Step 5: Remove Circle
To view the circle and the text on the stage, test the movie by pressing CTRL+Enter. They are present one after the other. Extend the timeline till frame 60. Now we are going to add the removeChild() function. So at frame 60, the Circle should be removed from the screen. With frame 60 selected, open the action window and type in removeChild(myCircle).
We are also adding a stop(); function to the code, to stop the test movie from looping. Now let's test the movie. Notice that the Circle Stays for 2 seconds and disappears. It is due to the removeChild() function.
Conclusion
The position of the objects can be controlled by altering the x and y axis. Other object properties that can be changed are skew, size, font, font size and many more.
About this tutorial
Internet Services and Social Networks Tutorials from HowTech published this 2:12 video tutorial on October 26, 2013. It has been watched 13,219 times on YouTube.
- Category
- Howto & Style
- Duration
- 2:12
- Published
- October 26, 2013
- Views
- 13,219
- Likes
- 51
Share
Further reading
-
addChild and removeChild - CoursesWeb
coursesweb.net
addChild() and removeChild() are methods which add and remove visual elements on the stage. addChild addChild is an ActionScript function that adds visual elements in the Flash presentation. It's general syntax is: addC…
-
AddChild - Adobe ActionScript® 3 (AS3 Flex) API Reference
help.adobe.com
Filters: Retrieving Data from Server... Retrieving Data from Server... mx.states AddChild - AS3 Flex: Properties | Properties | Constructor | Methods | Global ...
-
actionscript 3 - Correct use of addChild - Stack Overflow
stackoverflow.com
Each SWF file has an associated ActionScript class, known as the main class of the SWF file which extends a display object. From this class or any child within the hierarchy you may call addChild(). The following are eq…
-
flash - addChild() in Actionscript 3 - Stack Overflow
stackoverflow.com
I have tried parent.addChild(c) and stage.addChild(c); nothing seems to show them. (note my stage is 350 width and 700 height) flash actionscript-3 actionscript
This tutorial in other languages
- FRComment utiliser addChild dans Action Script
- ESCómo utilizar AddChild en Action Script
- PTComo usar AddChild em Action Script
- ITCome utilizzare addChild in Action Script
- DEWie zu verwenden AddChild in Action Script
- NLHoe te gebruiken addChild in Action Script
- RUКак использовать AddChild в Action Script
- PLJak korzystać addChild w Action Script
- JAどのようにアクションスクリプトでの使用にaddChildへ
- ARكيفية استخدام Addchild في سيناريو العمل
- HIकैसे कार्रवाई स्क्रिप्ट में उपयोग करने के लिए addChild
- IDCara Gunakan addChild in Action Script