You should not attempt any complex assignments or run any functions
outside of a function.

Tracy

 

________________________________

From: [email protected] [mailto:[email protected]] On
Behalf Of Paul Andrews
Sent: Wednesday, January 07, 2009 3:34 AM
To: [email protected]
Subject: Re: [flexcoders]Scope issue - class variable not set

 

----- Original Message ----- 

        From: dorkie dork from dorktown
<mailto:[email protected]>  

        To: [email protected]
<mailto:[email protected]>  

        Sent: Wednesday, January 07, 2009 8:08 AM

        Subject: [flexcoders]Scope issue - class variable not set

         

        Hi all,
        It seems setting a class variable is not happening until after
all my code is run. 
        
        When I do this:
        
        this.anchorName = anchorName;
        setState(stateName);
        
        the class variable "anchorName" isn't set. 
        the setState method is called and then the method is exited. 
        then the debugger loops back into the same method again like it
wasn't called but this time the class level variable is set before hand?
        
        What is going on? 

         

It's difficullt to tell from your snippet. You refer to a class variable
yet you are setting an instance variable and there is no context about
how that code is called, whether it's an instance method or a class
method. Your use of 'this' implies an instance method and if you are
assuming that the unqualified anchorName refers to a class method, you
would be wrong. Your assignment is setting the same instance variable to
itself. To refer to the class instance inside the instance method use
MyClassName.anchorName.

 

Paul



dorkie dork from twilight zone town



 

Reply via email to