Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 8 of 8
  1. #1
    Regular Coder tpeck's Avatar
    Join Date
    Oct 2002
    Location
    Sydney, Australia
    Posts
    882
    Thanks
    53
    Thanked 6 Times in 5 Posts

    linking flashsound files together

    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

    etc.

    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.

    Thanks.
    The difference between genius and stupidity is that genius has its limits. (Albert Einstein)

  • #2
    Regular Coder
    Join Date
    Nov 2008
    Posts
    165
    Thanks
    0
    Thanked 0 Times in 0 Posts
    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

  • #3
    Regular Coder tpeck's Avatar
    Join Date
    Oct 2002
    Location
    Sydney, Australia
    Posts
    882
    Thanks
    53
    Thanked 6 Times in 5 Posts
    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.
    The difference between genius and stupidity is that genius has its limits. (Albert Einstein)

  • #4
    Senior Coder gnomeontherun's Avatar
    Join Date
    Sep 2007
    Location
    Houston
    Posts
    2,846
    Thanks
    10
    Thanked 238 Times in 229 Posts
    Well there is a onSoundComplete which allows you to execute another function after the sound finishes.

    http://www.kennybellew.com/tutorial/complete.htm

    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.
    jeremy - gnomeontherun
    Educated questions often get educated answers, and simple questions often get simple answers.

  • #5
    Regular Coder tpeck's Avatar
    Join Date
    Oct 2002
    Location
    Sydney, Australia
    Posts
    882
    Thanks
    53
    Thanked 6 Times in 5 Posts
    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:

    Code:
    myMusic.onSoundComplete = function() { 
     _root.myNextSong.loadSound("sample02.mp3");
     _root.myNextSound.start();
    }
    ...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.
    The difference between genius and stupidity is that genius has its limits. (Albert Einstein)

  • #6
    Regular Coder tpeck's Avatar
    Join Date
    Oct 2002
    Location
    Sydney, Australia
    Posts
    882
    Thanks
    53
    Thanked 6 Times in 5 Posts
    I've searched around and found this code which appears to link a sound to another upon completion of the first sound:

    Code:
    onClipEvent (load) {
    	function nextSound() {
    		myLoop.start();
    	}
    	myLoop = new Sound(this);
    	myLoop.attachSound("2.mp3");
    	myLoop.start();
    	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.
    The difference between genius and stupidity is that genius has its limits. (Albert Einstein)

  • #7
    Senior Coder gnomeontherun's Avatar
    Join Date
    Sep 2007
    Location
    Houston
    Posts
    2,846
    Thanks
    10
    Thanked 238 Times in 229 Posts
    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.
    jeremy - gnomeontherun
    Educated questions often get educated answers, and simple questions often get simple answers.

  • #8
    Senior Coder gnomeontherun's Avatar
    Join Date
    Sep 2007
    Location
    Houston
    Posts
    2,846
    Thanks
    10
    Thanked 238 Times in 229 Posts
    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.

    Code:
    stop();
    
    var myLoop = new Sound;
    var quantity = 3;
    var indexSong = 1;
    var indexDelay = 0;
    var delay = new Array;
    
    delay = ["5000", 
    		 "500", 
    		 "2000"];
    
    function nextSound(index) {
    	if (_root.indexSong == 0) {
    		trace("End of Clips");
    		myLoop.stop();
    	}
    	else {
    		clearInterval(interval);
    		trace(index);
    		trace(delay[_root.indexDelay]);
    		myLoop.attachSound(index+".mp3");
    		myLoop.start();
    		if (index < _root.quantity) {
    			_root.indexSong++;
    			_root.indexDelay++;
    		}
    		else {
    			_root.indexSong = 0;
    		}
    	}
    }
    
    myLoop.onSoundComplete = function() {
    	var interval = setInterval(nextSound, delay[_root.indexDelay], _root.indexSong);
    }
    
    nextSound(indexSong);
    jeremy - gnomeontherun
    Educated questions often get educated answers, and simple questions often get simple answers.


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •