View Full Version : linking flashsound files together

12-08-2008, 07:39 AM
I have a working (but I guess limited) knowledge of FlashSound; that is, I can make an unlimited number of buttons play sounds in an HTML page using flashsound.js.

OK, so I have an exported .swf file that contains all the many sounds that I can play one at a time by calling them in the usual way.

Actually, it's a scene from a movie. Actors speaking their parts.

(button) Actor 1: speech#1

(button) Actor 2: speech#2

(button) Actor 1: speech#3

(button) Actor 3: speech#4


I can already hit the buttons just as above and play the actor's lines singly, (this I want to be able to do), but also, I want to add a single button that when pressed takes the existing speech sounds and plays them in sequence.

Of course, I could edit/join the sounds in an external editor into a very long .wav and import it and play the single long file as another flashsound, but that would duplicate the sounds and...well, you know.

So my question is how do I use the existing imported speech sounds and create a single button link that, in effect, links them all together and plays the entire scene in one fell swoop? And halves the .swf file size?

I hope I have explained it well enough.


12-08-2008, 12:34 PM
Hard to understand what you are trying to do. You just want to play the sounds in sequence after pressing the play button?... if so ... you can just add an event listener which will activate the next play when the one before finishes. If this is what you are trying to do then I can cook up some code for you..... let me know

12-08-2008, 06:38 PM
That's correct. I want to play some 30 or so spoken lines from a scene in sequence when I hit a particular button. I imagine it is ActionScript code I am after, but it is beyond me.

1.mp3 + 2.mp3 + 3.mp3+ 4.mp3 + 5.mp3 etc.

Just hit the button and listen to the entire scene. But probably need to add short silences of varying length here and there to make it sound natural.

1.mp3 + pause(0.1 sec) + 2.mp3 + pause(0.05 sec) + 3.mp3 + pause(0.06 sec) + 4.mp3 + 5.mp3 + pause(1 sec) + 6.mp3 etc.

12-09-2008, 11:59 PM
Well there is a onSoundComplete which allows you to execute another function after the sound finishes.


You could have an array which has the sound instance names, and then an array with the pause durations, and have a function which handles the logic, or you can just have a bunch of those onSoundComplete functions.

12-11-2008, 12:41 AM
Thanks Jeremy.

I have studied the tutorial you suggest but this is my first venture into the world of ActionScript and I don't know how to build an array - or exactly where to write anything.

I think I need to write something like:

myMusic.onSoundComplete = function() {

...but I really don't know where to begin. Can you show me how such an array would be built, say with three sounds and three different length pauses to choose from.

I should be able to then extrapolate from there. Thanks.

12-13-2008, 01:47 AM
I've searched around and found this code which appears to link a sound to another upon completion of the first sound:

onClipEvent (load) {
function nextSound() {
myLoop = new Sound(this);
myLoop.onSoundComplete = nextSound;

I must be putting it in the wrong place because playing the first sound doesn't add the second:


Can someone please advise how to get these two sounds to play sequentially, then I'll try to link some more and delve into arrays? Thanks.

12-13-2008, 11:23 AM
Is there anyway you can post the FLA for me? Sometimes it just takes messing with the actual files to know what to suggest. Otherwise I don't think that code loop is doing quite what you say. Are you also putting the sounds directly on the timeline? If so there is no need to manage it with Actionscript...I'd think.

12-13-2008, 06:15 PM
So this code works, except for the interval. I don't know why at the moment, but maybe it will be helpful. It should be placed on the first frame of the main timeline, and will run without any assistance.


var myLoop = new Sound;
var quantity = 3;
var indexSong = 1;
var indexDelay = 0;
var delay = new Array;

delay = ["5000",

function nextSound(index) {
if (_root.indexSong == 0) {
trace("End of Clips");
else {
if (index < _root.quantity) {
else {
_root.indexSong = 0;

myLoop.onSoundComplete = function() {
var interval = setInterval(nextSound, delay[_root.indexDelay], _root.indexSong);