[FMX] clearing variables

I have an email section that I split into two pages, one for each recipient. After emailing one person, then returning to the first page where the user can choose who to send to, and selecting the other choice, the old message still appears. How do you clear those variables after the message has been sent?


u can use delete command

delete varName

so when it come back it return void ,null or undefined


[email protected]

you can also set them to equal nothing… sometimes this is beter than deleting them, but in most cases it wouldn’t make any difference to the viewer of the project. In this case you would do something like


if myVariable had a value before that point in time, it would, after this script have a blank variable.

The difference relates to boolian logic mostly. That is to say… some of us write scripts which ask if a variable is “true” or “false”. A variable which doesn’t exist, is considered false, a variable which exists, but has, or does not have value, is considered true.


if u clean variable like

myVariable=""; and later u make a check in some where it will not return a null value … it means still var. entity is there i mean…
if (myVariable==viod(myVariable)){} or if (myVariable==null){}

i also feel boolian var is better

[email protected]

Thanks to you both!

*Originally posted by david *
**A variable which doesn’t exist, is considered false, a variable which exists, but has, or does not have value, is considered true. **

Thats not entirely true. :wink: A non-existant variable, when evaluated, is undefined which is as good as false. However, an existing variable can have a value which can also have it to be considered false. Checking for that variable will return false if its current value is false.

For example, setting a variable to be either a string, 0, false, null, undefined or a nonexisting variable (ie. undefined) will make it have a value which, if directly evaluated in an if, would result in a false return…

myVar = 0;
if (myVar){ // not called }

Also, there are differences in saying something like

myVar = undefined;
delete myVar;

setting myVar to undefined sets the value of that variable to be of the value undefined. Deleteing the variable actually gets rid of the variable alltogether even though if that variable is tested for, the return evalutation is undefined.

When this becomes important is when dealing with memory management (something which you would hardly ever worry about with Flash), for…in loops as deleted variables will not show where as variables set to be undefined would, and when dealing with variables through multiple heirarchical chains.

An example of the third would be the following:

MovieClip.prototype.value = 1;

trace(myMovie_mc.value); // traces 10

trace(myMovie_mc.value); // traces undefined

delete myMovie_mc.value;
trace(myMovie_mc.value); // traces 1

However, under the circumstances, in terms of the current context, Davids initial suggestion of


prooves to be the best IMHO and is all you really need to do for forms and things of the such.

oops… you’re right Sen… that was a typo. :slight_smile:

thanks for clarifying me