This content has been marked as final. Show 10 replies
since the Tween is residing within a function it is local to that function only, this means that in order to get the onMotionFinished handler to operate, it must reside within the smae function. you should restructure the code like so:
it's not just that it's local to newFunction. it's that newFUnctionXX isn't called and so the onMotionFinished method doesn't execute.
and if you call newFUnctionXX before the tween is created, the onMotionFinished method will be applied to a non-existent tween and will have no effect.
however, if you used the following, you'd have no problem:
Yes, I know this. However, I would need to separate functions since I would be using the first one in more occasions - different behaviour after the tween is finished based upon which button has been pressed - therefore I can not put the onMotionFinished there for good, you see?
edit - sorry, I misread to code. Still, same case as the other reply - I can't include the other function into the first one for good since I would need to be using different behaviour in dofferent cases after the motion is finished :(
can I not somehow export the tween name or something please?
@lubi: sure, but you could also put a conditional statement in the onMotionFinished method to handle different situtations.
@kglad: hey that's cool, would that be because in this situation the functions are being defined as variables? I had thought that vars were only local to thier parent function and didn't exist out side them.
no, using a named function has nothing to do with the problem you correctly pointed-out: prefixing the tween with var makes the tween name local to the function in which it's defined.
i was just pointing out that removing the var prefix would allow the onMotionFinished method to be moved outside that function. but then you have to be careful to not execute the code defining the onMotionFinished method until the tween itself exists.
You would be surprised be this doesn't work:
@lubi: you may need to use:
set a 'trace' in there to make sure it's getting through.
@kglad: cool, I didn't realize that you could do that. handy.
ok, cool, thanks guys.