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

flash actionscript : onSoundComplete


moniwhitt
4/11/2004 5:43:01 AM
Hi,
I'm trying to use the onSoundComplete event so that the sound file will finish
playing completelly before moving to the next frame. I can't make it work. I
was wondering if anybody would have an example of how to use this code so the
sound will finish playing before jumping to the next frame...?

Thank you for you help!
urami_
4/11/2004 1:53:31 PM


[quoted text, click to view]

how abut you post what you have done so far , part that did not work
and based on your arrangement we try to fix it .
Off hand syntax might not necessarily help you if does not fit in your arrangement.

Start with how you initialize your sound in the first place ....



--

Regards


urami_*



<no>
http://flashfugitive.com/
</no>

aparna
4/12/2004 11:40:21 AM
Just some lines I used to get the sound playing and then stopping...

newSound.loadSound("here specify the location");
newSound.start();
newSound.onSoundComplete = function() {
"write the function here"
};

These lines work fine for me........

MacAddict001
5/13/2004 1:33:28 AM
urami,

I know you have been here for quite some time moderating and helping people,
so when I saw your name I knew you'd probably be able to help me.

I am having similar problems with onsoundcomplete, but a little different than
what this person was doing. I set up 2 new sound objects on the main timeline,
incomingMortar and explosion, and attached linked sound files from the library:
(yes they are named and checked for export)

explosion = new Sound();
explosion.attachSound("mortarExplosion");
incoming1 = new Sound();
incoming1.attachSound("incomingMortar");

I then set up 2 functions to call from various points in the main timeline:

function playExplosion() {
trace("incoming Complete");
explosion1.start();
_root.play();
return true;
}
function incomingMortarFire() {
incoming1.onSoundComplete = playExplosion;
incoming1.start();
}

The first just gets called within incomingMortarFire, but is necessarry to
complete the "effect" of an incoming round and tell the main timeline to 'play'
continuing into the blast animation for effect.

Now, at various points in the main timeline, I use just
incomingMortarFire(); stop(); in the spec'd frame when I need the soundclips
played back to back. It works, but here's the problem - it only works at
random. Sometimes it will work 3 or 4 times in a row, but then it stops
working. It's like it loses what the sound objects are and fails continue on to
the play(); action in the playExplosion function. It's really strange. If I
refresh the page, it might not even do the action once - stopping the playhead
on the fist frame I called it on. But then if I refresh again, it will go
through 3 or 4 of them. OH.. and this is on Mac OSX AND PC XP pro.

I have tried everything... even making MCs and doing onClipEvent s to create
these functions and sound objects, but it still randomly stops without playing
the sounds.

I thought something was getting tweaked in the publish, but I
uninstalled/reinstalled and still the same random "no firing." I even put trace
actions in to see where it was stopping.... but as I said.. sometimes it does,
sometimes it doesnt. Is there a bug to the onsoundcomplete action that I dont
know about? If so, whats the workaround, if any?

Thanks very much in advance.

MacAddict001
5/13/2004 2:28:43 PM
Me again.....

OK, having searched through the posts, I found that flash only has 8 sound
channels..... So, being that i have a number of other sounds playing at random
during the same time as I call the functions I outlined above, I eliminated
that possible problem by removing the other sounds. Still the same problem.
Sometimes the sounds play through... other times it stops and seems to never
reach the play() command in the explosion function.

Being that this is happening at random on any platform, maybe its the Flash
player?

Thanks for your input.
AddThis Social Bookmark Button