This example makes me wonder:

If I was to write this in AS2, it would probably look like:

Think of it like this: "createEmptyMovieClip" is functionally equivilent to "new MovieClip" PLUS "addChild". The benefit of seperating them is that you can add things to and remove things from the display list anytime you want, instead of creating a new movie clip and having it stuck in the scope you created it in.

Think, for example, of a drag and drop paradigm. You can literally have something start dragging when you click it, only instead of just dragging, it is removed from its current container and placed in "_root", so that it's on top of everything, and then when you drop it on another container, it is actually, physically (as far as that goes in the world of computers) added to that container. You didn't just move it from one array to another behind the scenes, you actually took the movie clip itself and changed which timeline it exists on, all without losing the state of the object.

var game_bg:MovieClip = new MovieClip();
gameworld.addChild( game_bg );
gameworld.addChild( game_bg );
...

Think of the DisplayList as the stage, and addChild adds the movie clip to the stage at the next highest depth. Adding it again would do one of two things (depending on exactly how it was implemented), either remove it from the display list and add it back, which effectively did nothing, or throw an error because it was already on the display list. I'm pretty sure display objects can only have one parent.

ryanm
_______________________________________________
Flashcoders mailing list
Flashcoders@chattyfig.figleaf.com
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders

Reply via email to