PDA

View Full Version : reset a variable?


MaryAnneL
01-25-2007, 12:56 PM
Probably a silly question, but what is the preferred method to clear (reset) a variable once it's been defined?

Say I have a variable like this:

var strName:String = "MaryAnne";

and later on I need to reset the variable. Would I simply do this:

var strName = "";

or is there some kind of Flash function to do this?

Thanks!

Noct
01-25-2007, 06:53 PM
Why would you need to "reset" a variable to nothing?
The entire point of a variable is to hold data, if you don't need that data, don't call it.
When you need it to be something else, just declare it as something else.

var strName:String = "MaryAnne";
strName="BillySue";

CyanBlue
01-25-2007, 07:17 PM
When you need to reset the variable, you do not want to put 'var' in front... It's only used once when you declare it... I think that's where your original problem was...

MaryAnneL
01-25-2007, 07:36 PM
Thanks for straightening me out Noct and CyanBlue. =)