Groups | Blog | Home
all groups > flash actionscript > may 2004 >

flash actionscript : Help creating "start" sync in actionscript


aamay
5/19/2004 9:53:18 PM
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?
kglad
5/20/2004 12:04:43 AM
s = new Sound();
s.attachSound(sndID);

if (!playing) {
_root.s.start();
playing=1;
}

_root.s.onSoundComplete = function() {
playing=0;
aamay
5/20/2004 4:01:43 PM
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.
kglad
5/20/2004 4:07:38 PM
there's nothing in the code i listed that would stop a sound. you must that code elsewhere.

aamay
5/21/2004 5:43:19 PM
[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.
AddThis Social Bookmark Button