PDA

View Full Version : Playing a sound in the middle of the scene



mikko@mikkohopia.net
23 Feb 2012, 12:25 AM
Is it possible to play a sound in the middle of the scene without any user activity? I played around with jQuery delay() without any success.

In Flash you can just add a keyframe and some keyframe based actions to do this. Is this possible in Sencha Animator?

If I add an invisible object, say transparent png image, so is there a load event where I could add js to play a sound?

Cheers!

arnebech
23 Feb 2012, 8:13 AM
Currently there is no way to tie JS to a keyframe in Animator.

One advanced way of accomplishing it, would be to add an hidden animation, with two keyframes, and listen for the 'animationEnd' event fired by the object when the animation is done and use that to fire your event.

A simpler approach would be to add a timeout to your Start Action of the scene. For example:



//get stage of first scene
var stageElement = document.querySelector('.AN-sObj-stage')


//create timeout at 1000ms (1 second)
setTimeout(function(){
//change the background color of the stage to red
stageElement.style.backgroundColor = "red";
},1000)

mikko@mikkohopia.net
24 Feb 2012, 6:04 AM
Ok, thank you very much for the help. I think I'll use setTimeout for this.