-
Learning Extendscript / Keep getting NaN
Hey there. I’m brand new to the Creative Cow scene as well as Javascript so I apologize for what may seem like a simple question. I’m teaching myself Javascript so I’m having problems understanding how to implement functions. So far I understand the very basics, so now I’m creating a test script to understand the usage and implementation of functions.
Currently, the problem I’m running into is that I keep getting NAN in my alert. I know it means “Not A Number”, which is crazy, because if I put the alert inside the testFunction it clearly say “2”. But I wanted to put the alert for the results of the testFunction inside of another function so I could see how the value being returned from testFunction could be used in other parts of the code. This test is also a way for me to understand how to write multiple functions, have them execute in a specific order, and pass the data around. I’m currently reading the AE Scripting Guides, looking through several script examples, but it seems I can’t find the answer for something so trivial. Any help or explanation with this is greatly appreciated.
var myComp = app.project.activeItem;
if (myComp == null || (myComp instanceof CompItem) == false ){
alert("Please select a Composition");
}else{
testFunction(1,1);
alertReturn();
};
function testFunction(a,b){
var results = a + b;
return(results);
};
function alertReturn(){
var a = testFunction();
alert(a);
};