# \[FMX\] clearing variables

**URL:** https://forum.kirupa.com/t/fmx-clearing-variables/15777
**Category:** flash
**Created:** [March 18, 2003, 12:47am UTC](https://forum.kirupa.com/t/fmx-clearing-variables/15777 "2003-03-18T00:47:42Z")
**Posts on this page:** 7
**Page:** 1

<div class="post-metadata">

### Author: ![AnonymousCaller](https://avatars.discourse-cdn.com/v4/letter/a/d6d6ee/32.png) [@AnonymousCaller](https://forum.kirupa.com/u/AnonymousCaller)
#### Post date: [March 18, 2003, 12:47am UTC](https://forum.kirupa.com/t/fmx-clearing-variables/15777/1 "2003-03-18T00:47:42Z")

</div>

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?  
Thanks,  
AC

---

<div class="post-metadata">

### Author: ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)
#### Post date: [March 18, 2003, 5:11am UTC](https://forum.kirupa.com/t/fmx-clearing-variables/15777/2 "2003-03-18T05:11:33Z")

</div>

hi,

u can use delete command

delete varName

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

regards

ajok  
[ajok@indiatimes.com](mailto:ajok@indiatimes.com)

---

<div class="post-metadata">

### Author: ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)
#### Post date: [March 18, 2003, 6:09am UTC](https://forum.kirupa.com/t/fmx-clearing-variables/15777/3 "2003-03-18T06:09:45Z")

</div>

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

myVariable="";

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.

---

<div class="post-metadata">

### Author: ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)
#### Post date: [March 18, 2003, 8:17am UTC](https://forum.kirupa.com/t/fmx-clearing-variables/15777/4 "2003-03-18T08:17:28Z")

</div>

hi,

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

regards  
ajok  
[ajok@indiatimes.com](mailto:ajok@indiatimes.com)

---

<div class="post-metadata">

### Author: ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)
#### Post date: [March 18, 2003, 6:04pm UTC](https://forum.kirupa.com/t/fmx-clearing-variables/15777/5 "2003-03-18T18:04:22Z")

</div>

Thanks to you both!  
Cheers,  
AC

---

<div class="post-metadata">

### Author: ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)
#### Post date: [March 18, 2003, 6:38pm UTC](https://forum.kirupa.com/t/fmx-clearing-variables/15777/6 "2003-03-18T18:38:26Z")

</div>

> \*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. 😉 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;  
and  
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;  
myMovie\_mc.value=10;

trace(myMovie\_mc.value); // traces 10

myMovie\_mc.value=undefined;  
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

myVariable=“”;

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

---

<div class="post-metadata">

### Author: ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)
#### Post date: [March 19, 2003, 9:01am UTC](https://forum.kirupa.com/t/fmx-clearing-variables/15777/7 "2003-03-19T09:01:27Z")

</div>

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

thanks for clarifying me
