AS2 to AS3 Babysteps - Part 3 — Where’s attachMovie()?
Reynaldo November 4th, 2007
Well, as you may have noticed, attachMovie() has been removed from AS3. When I first saw this, the first thing that went through my mind was “how the heck am I gonna attach stuff from the library now?” lol. Never fear my fellow Actionscriptors, this is the way:
this.addChild(new myClip());
All this does is create an instance a movieclip in the library instance named myClip and adds it to the root’s (oops, meant timeline’s) displayList. This is definitely more object oriented than the old attachClip method.
Keep in mind that when clicking on “Export for Actionscript” on the linkage menu for the movieclip, flash is gonna warn you that a class for the symbol will be automatically created and it’ll use the symbols name as the class name.
Ok, that’s all cool and dandy, but now here comes the fun part! Actually making use of that class
, this is how:
package{ import flash.display.MovieClip; public class myClip extends MovieClip{ public function myClip(){ trace("Look Ma!!! Im coding in AS3"); } } }
You have to save your class to the same folder where your fla file is, at least for this example.
Happy coding!! ![]()



