AS2 to AS3 Baby Steps - Part 6 - Attaching symbols on/to the stage

Reynaldo December 3rd, 2007

In AS2, symbols that were on the stage were already “added to the stage” and you really didn’t have to do anything about it. It was already there. Well, in AS3 you really can’t interact with the symbol already on stage unless it’s added to the Display List.

Linking symbols from the library in AS3 also differs from what we are used to seeing in AS2. Here’s what were used to:

1
2
3
var mcNewClip:MovieClip = this.createEmptyMovieClip("mcNewClip", 10);
var mcAttachedClip:MovieClip = this.mcNewClip.attachMovie("mcLibClip", 20);
trace(this.mcAlreadyOnStasge)

This is how it looks in AS3:

1
2
3
4
var mcNewClip:Sprite = new Sprite();
var mcAttachedClip:AttachedClip = new AttachedClip();
mcNewClip.addChild(mcAttachedClip);
addChild(mcAlreadyOnStage);

For the clip in the library (mcAttachedClip), in the linkage id properties, I would have linked it to a AttachedClip Class and left the base class as flash.display.MovieClip. Since we haven’t created an AttachClip Class, flash would create one for us (with no code). We can create a AttachClip Class and put functionality into it if we wated to, but in this cass all we want is for th eclip to be visible.

Trackback URI | Comments RSS

Leave a Reply

  • Friends

  • Props

  • Donations

  • website counter
  • Archives

  • Feedburner