The difference between these two approaches is scope.
 
In your first example u create a variable on the instance of the class u are working in. This variable exists as long as that instance has a reference somewhere in the application.
 
In the second example u create a variable inside a function definition. This means that at the }, the end of the function this variable is destroyed.
 
 
Greetz Erik


From: [email protected] [mailto:[EMAIL PROTECTED] On Behalf Of [EMAIL PROTECTED]
Sent: woensdag 25 mei 2005 4:41
To: [email protected]
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:Number
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