You should instead use a callback function. You can do that like this:
function fSwap(funcName, callback) {
window[funcName] = callback;
}
fSwap("drawScene", function drawScene() { /* Do something */ });
To answer your question directly, what's going wrong is that you're assigning a value to an evaluated piece of code. That won't work. What would work would be:
function fSwap(funcName, code) {
eval(funcName+' = '+code);
}
but please do not do it this way. The other way, using callback functions, is much cleaner. It's almost always better not to use eval
whenever it's not absolutely required to use it. (According to your comment, apparently it is absolutely required to use strings, so do use this piece of code).