delayedEvent.reset(2) throws error
Hey fellow Snappers, I'm trying to use the sample script for Delayed Callback events from the API manual but I'm getting an error for:
09:53:10 [Scenarium] TypeError: cannot read property 'reset' of undefined
at [anon] (DestroyBalls.js:14) preventsyield
*script is attached to a scene object and triggered for Tapped (or OnAwake)
///////////////////
Script is pretty basic:
var delayedEvent = script.createEvent("DelayedCallbackEvent").bind(DestroyBall);
function DestroyBall(e) {
var ball = script.getSceneObject().getChild(0);
ball.destroy();
}
// Start with a 2 second delay
delayedEvent.reset(2);
Any ideas? Much appreciated!
Hi, @...
try splitting first line of code into two :
var delayedEvent = script.createEvent("DelayedCallbackEvent");delayedEvent.bind(DestroyBall)
Yepp this solves the issue; thanks a lot :) Olha