- Home /
iTween - calling functions on oncomplete doesn't work if the function is declared as a variable
Hi - so I have a weird catch22 happening - I'm trying to build a game for iPhone in javascript. iPhone requires that you declare your functions as variables (I think), like this:
var myFunction = function(){ };
but in order for iTween's "oncomplete" functionality to work, the function must be declared like this:
function myFunction(){ };
How do I get these two things to play nicely together. This is what one of my itween functions looks like:
iTween.MoveTo(lighter,{"y":-.8, "z":-.4, "time":1,"easeType": "easeInOutQuad","oncomplete":"lighterEnable"});
Answer by Wolfram · Jun 13, 2012 at 04:27 PM
Your assumption is not correct. Maybe you're accidentally trying to do something with "myFunction" in your code that's not allowed for functions, and since your "fix" removes the compiler warning, it seems like it is correct.
Can you show us and/or check for yourself the script/the places where you use/access "myFunction" (or referring to your iTween problem, "lighterEnable")? There must be a problem there (e.g., forgot the "()" when calling it, assigning it to something, ...)
You're right - the assumption was an issue resulting from my previous issue, which you solved - I was not accurately referencing the script properly by casting its type. I will delete this quesiton if you remove your answer (or I can just accept this as the answer). Regardless, thank you for your help!
No need to delete valid questions, this is a knowledge database, so in case somebody stumbles over a similar problem at some point, this might help him. Feel free to accept this answer, as it did solve your question ;-)