Download Example Files
This is just a quick little tip on how to add symbols you've marked for linking in the library to the stage. There is a new way to handle adding things to the display list and this is the old way:
Actionscript:
-
var holder_mc:MovieClip = this.createEmptyMovieClip("holder_mc", this.getNextHighestDepth());
-
var box_mc:MovieClip = holder_mc.attachMovie("box", "box1_mc", holder_mc.getNextHighestDepth(), {_x: 100, _y: 50});
Here is the AS3 equivalent of the above:
Actionscript:
-
var holder:Sprite = new Sprite();
-
var box:Box = new Box();
-
-
box.x = 100;
-
box.y = 50;
-
-
holder.addChild(box);
-
this.addChild(holder);
Notice in the exampe files that I've linked the box to a class to a class called Box and a base class of flash.display.MovieClip (the default when you check export for AS). Even though I never created a Box class, Flash thinks that there isn't one and creates one automatically for me (with no code in it of course). This is the new way to apply "linkage IDs" to exported clips in AS3. You can go ahead and create a Box class if you'd like but there is no need for it because we aren't adding any functionality to this particular case, just need to get it out onto the stage through code.
It is kind of nice being able to set up a sprite or movie clip and initialize everything before adding it to the stage.
Tags: AS2, AS3, code conversion, linked symbols, stage