"this" can also be used to refer an instance's member variable explicitly. 
Since scoping rules allow for a local variable (in a method) to be named the 
same as an instance member variable, "this" is required to differentiate 
between the two.
 
(Sorry about the html mail)
 
Scott

        -----Original Message----- 
        From: [EMAIL PROTECTED] on behalf of A.Cicak 
        Sent: Fri 28/10/2005 6:32 PM 
        To: flashcoders@chattyfig.figleaf.com 
        Cc: 
        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

Reply via email to