What I don't get is why it needs "this.addChild" instead of just addChild. I've been sick of the keyword "this" for a long time and have since avoided it in AS2.

Any reason that it needs to be back in for AS3?

Maybe because it's one of the most useful scope references ever invented?

The fundamental concept that you seem to miss is that "addChild" is meaningless by itself, it is a method of an object (in proper OOP development), and if you just say "addChild", who is adding the child? You need a reference. You could do it like this if you like:

class Game extends MovieClip {
   var world:MovieClip;
   var bg:MovieClip;
   function Game(){
       var GameReference:Game = this;
       world = new MovieClip();

       GameReference.addChild( world );

       bg = new MovieClip();
       world.addChild( bg );
   }
}

The point is, you shouldn't use functions that aren't attached to objects, it's bad form, and it's thoroughlly confusing to people who later have to maintain your code. Besides, it makes you look like one of those wannabe-programmer VB guys. ;-)

ryanm
_______________________________________________
Flashcoders mailing list
[email protected]
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders

Reply via email to