If you declare the variable in the main code of the script, you should use the variable directly inside the function, without using it as an argument. This function uses the variable that you gave as an argument. Not the global one. Although they have the same name, they are different variables. And the return works as asigning the variable to something. Try something like
var BpreNull;
newNull = CreatepcNull(BpreNull, curBtwnComp, curBtwnComp.duration, BdestComp, q, threeD, BcName, BpreName);
alert(newNull.name)
OR
If you do not want to use another variable, try removing BpreNull from the function arguments. And remove the return.
Tell me if this worked. If not, we will figure it out.
Andrei
My Envato portfolio.