Dynamic variable edited through a function?

Solution - You can refer to variables through other variables by wrapping them in _root[ & ]. So for my example I can use _root[keyToSet] = newKey to set a variable from inside my function.


Hullooooo again. I’ve hit another snag with my project and Im not sure how to proceed.

I have a function that is used to customize the controls, and I pass a variable to it for updating the screen with which keys are assigned to what controls.

For examples sake, this is the code:

upKey = 87;

upKeyBTN.onRelease = function(){
     setCustomKeys(upKey);
}

function setCustomKeys(keyToSet){
     newKey = *key pressed by user*;
     keyToSet = newKey;
}

What I can’t seem to do is get upKey updated with the new key from inside the function. As my example shows, I tried using keyToSet = newKey, but that doesn’t seem to work. I need to use upKey in a few other places in the function too, so how can I make a direct reference to it from inside the function?

The whole point of doing it this way is so that I can customize each key with just one function.

Any ideas on how I can achieve this? Thanks!=)

Brendan