I have a javascript function that on mouseover plays a sound in a swf file. I use actionscript to play the sound: playing = false; s = new Sound(); s.attachSound(sndID); . . . if (playing==false) { _root.s.start(); playing=true; } _root.s.onSoundComplete = function() { playing=false; Sound.stop(); } The problem is that if the user continually triggers the mouseover, the sound plays over itself (echo effect) - like event sync in Flash. How can I create start sync in actionscript, so that the sound will play in only one channel?
s = new Sound(); s.attachSound(sndID); if (!playing) { _root.s.start(); playing=1; } _root.s.onSoundComplete = function() { playing=0;
This solution seems to work, but if you move the mouse to produce three or four quick events, the sound stops playing altogether, on the current region or any other mouseover region. I have to refresh the page to restore sound.
there's nothing in the code i listed that would stop a sound. you must that code elsewhere.
[Second try replying to this message...replies don't get posted...] Very peculiar - today your suggested code doesn't play sound at all. I've recompiled half a dozen times. The original version plays as it did before. File names are all correct. To answer your question, all the action script is in the main (and only) timeline. First two statements are in frame 2, remaining statements (if(!playing)...etc.) in frame 4. The only function of this swf file is to play the sounds (from its library) that javascript passes to it in variable sndID.
Don't see what you're looking for? Try a search.
|