@Remek's answer is right if you are using jQuery to animate, but you also tagged TweenJS, so you can use call
, which queues a function call in a TweenJS queue.
createjs.Tween.get(obj)
.to({x:1000}, 3000, createjs.Ease.quadOut)
.call(function(tween) {
createjs.Sound.play("soundId");
});
You can use a call within a Tween queue, or at the end. Note that tweens also dispatch events, but only have a "change" event, and not a "complete" event because tweens can be looped, reversed, and constantly chained to add additional animations, so they don't really "complete". This is why the call
method exists.
The call
method also accepts parameters and a function scope.
http://www.createjs.com/docs/tweenjs/classes/Tween.html#method_call
Regarding your question about "human gestures", this applies mostly to mobile platforms, where you must click something to play a sound (which unlocks the audio context, so it just has to happen once). The latest SoundJS automatically handles that for you, automatically playing an empty sound when you press (even for a scroll). Note that using scrolls to do this has been deprecated, so the user may have to "click/tap" something to make this work properly - but SoundJS will handle unlocking for you in this case.
Cheers.