Can you be more specific about what you mean when you say "it keeps forgetting", or post a tiny but complete <mx:Application> that demonstrates the problem?

 

The meanings of 'var age' in your two examples are very different. Your second example would "forget" that you set age to 23, because you are setting a local (or temporary) variable in the compute function, and local variables go away when the function they are in returns. The first example would not "forget" the 23 because you are setting an instance variable on whatever the 'this' object is; instance variables last as long as the object itself.

 

- Gordon

 


From: flexcoders@yahoogroups.com [mailto:[EMAIL PROTECTED] On Behalf Of [EMAIL PROTECTED]
Sent: Tuesday, May 24, 2005 7:41 PM
To: flexcoders@yahoogroups.com
Subject: [flexcoders] Applications forgetting variables

 

I can not help but feel I have ran in to more problems than neccessary because my flex applicaitons forget variables. I mean I know from a code standpoint I am doing the right thing when I write my code but I think it forgets variables and I think this is causing me more stress than need be. What I want to know is how does someone go about making sure it does not forget variables I mean is this a way to do it:

If I have a function and a variable that looks like this say:

public var age:Num

public function compute(){

age = 23

}

but lets say that for some odd reason when you get to the compute function it keeps forgetting the age variable will this solve it to write the function like this:

public function compute(){

var age:Number

age = 23

}

If there is any other suggestions let me know

 



Yahoo! Groups Links

Reply via email to