i have a function that changes a root variable that i pass into it. the problem is that the changes to the variable are only present in the function, once the function ends the new value disappears as well. here is a simple example of what i'm talking about:
the function changes the variable within its own scope, but is there a way for it to change the variable outside of its own scope as well? In my real code, the code within the function is in an onEnterFrame event, so i need it to update the variable every frame....Code://there's the variable i want to manipulate fakeVar=100; function mult(whichVar){ //let's multiple the variable by 2. whichVar*=2; trace(whichVar) // traces 200...correct. trace(fakeVar) //traces 100, the original value, not correct } box.onRelease=function(){ //call the function with the variable i want to update. mult(fakeVar) }




Reply With Quote