Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

how can I delete all variables? 1

Status
Not open for further replies.

timtom

Programmer
Jul 12, 2001
78
GB
Oh hello,
Is there a quick way to delete all my global variables? I know I can do

delete variable1;
delete var2;
delete var3;

etc.
but can I just drop everything in one line of actionscript perhaps?
cheers,
Sarah
 
You can execute all of your code in one line, not sure if this is what you meant. But, put the
Code:
_global.
header before the variable to delete the variables throuout the whole movie.

Code:
delete _global.var1; delete _global.var2;

Thats all I can think of!

FLASHfreak :)
- The Flash Experience
 
Did you really mean global variables as variables defined throughout the movie like...

_global.my_var1 = 10;
_global.my_var2 = "Hello World!";

Etc, etc...
If so, you could define a function on the first frame of your movie...
Code:
function killAllVariables(reference) {
    for (var i in reference) {
        if(typeof reference[i]=="string" ||typeof reference[i]=="number") {
            delete reference[i];
        }
    }
};

Then call this function with...

killAllVariables(_global);




 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top