No need to get hyper about "this". The matter stays that "this" used to be essential in AS1, thus probably why people still like to implicate him in their code. But I agree that putting "this" in an AS2 Class should be used only when necessary.
-----Original Message----- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of A.Cicak Sent: October 28, 2005 6:33 PM To: flashcoders@chattyfig.figleaf.com Subject: [Flashcoders] Re: Newbie AS3 question Well, I dont agree, "this" keyword refers to current class, so its only more typing to include it, and making code less readable. Only reason keyword "this" exists is if you want to pass reference to current object somewhere, in which case you must use "this". To me using "this" in your code makes you look like wannabe-programmer, :) But I gues its matter of taste. btw, old VB does not have "this" keyword, and if you were reffering to VB(.NET), it is more OOP and more complex than AS3, so I gues programmers in VB.NET (if there are some, since C# is there) are not wannabe-programmers :) "ryanm" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] >> 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 > Flashcoders@chattyfig.figleaf.com > http://chattyfig.figleaf.com/mailman/listinfo/flashcoders > _______________________________________________ Flashcoders mailing list Flashcoders@chattyfig.figleaf.com http://chattyfig.figleaf.com/mailman/listinfo/flashcoders _______________________________________________ Flashcoders mailing list Flashcoders@chattyfig.figleaf.com http://chattyfig.figleaf.com/mailman/listinfo/flashcoders