| flash sound problems
• | | | |
 | flash sound problems
by Gustav on Aug 16, 2006 at 5:18:32 pm |
I have 3 buttons, each of which have a sound file attatched to their 'down' states, which i have set to loop. I also have a mute button, which has 'stop all sounds' on it.
My problem is that when i play 1 loop, and then click one of the other buttons, it plays over the loop that is currently playing, instead of interrupting it.
please help, it is stressing me out, and i can only find tutorials for play/stop buttons for one sound file
thanks
gus
| | | | |
• | | | |  | Re: flash sound problems by Matt Klundt on Aug 16, 2006 at 5:32:22 pm |
Try starting the sounds with actionscript instead. Call stopAllSounds before starting the sound for that specific button.
sound1 = new Sound();
sound1.attachSound("linkageID");
myButton1.onPress = function() {
stopAllSounds();
sound1.start(0, 999);
}
"linkageID" refers to the linkage name given to a sound in your library. Matt -------------------- http://www.mcquillendesign.comhttp://www.mattfoxgames.com
| | | | |
• | | | |  | Re: flash sound problems by Gustav on Aug 16, 2006 at 7:08:05 pm |
thanks for the reply, i am a bit of a beginner and am not familiar with actionscript, so i have been trying to do it without. I would like to try your suggestion, but i'm not sure how, should i paste that actionscript into the actions of the button?
sorry
Gus
| | | | |
• | | | |  | Re: flash sound problems by Matt Klundt on Aug 16, 2006 at 7:16:44 pm |
Those actions would go on a keyframe in one of the layers, at the same frame as the buttons. (Placing actions on buttons themselves is possible, but is bad practice as experience will show you if you keep using it long enough.)
Be sure that the instance name of the button on the stage matches the name (myButton1). And then copy and paste the script two more times, changing the button name and sound variable names to match your needs. Matt -------------------- http://www.mcquillendesign.comhttp://www.mattfoxgames.com
| | | | |
• | | | |  | Re: flash sound problems by Gustav on Aug 16, 2006 at 7:46:35 pm |
ok, i have removed the sounds from the 'down' states of the buttons,
and i have put the actionscript in on 3 layers on the same frame as the buttons, and i have put the name of the sound files in the 'linkage id' bit, and changed the 'button1' things aswell,
i tried it and it doesnt play them in the live preview mode, havent tried testing it, because its a big project and takes ages to load, should it play them in live preview mode?
also, should i replace 'sound1' with anything?
cheers,
gus
| | | | |
• | | | |  | Re: flash sound problems by Matt Klundt on Aug 16, 2006 at 7:56:49 pm |
sound1 should change with each of the three sounds that need to play. Such as sound1, sound2, sound3. The linkage name on the attachSound() needs to change as well (match the linkage name on the sound in your library).
I think live preview only shows basic rollover states, and not any actionscript occurances. So I think you will have to test the movie to find out.
Also, the three scripts can be on the same layer, in fact I would suggest using only one layer for all actionscript. This way you can easily find your code without searching multiple places. Matt -------------------- http://www.mcquillendesign.comhttp://www.mattfoxgames.com
| | | | |
• | | | |  | Re: flash sound problems by Gustav on Aug 16, 2006 at 8:11:01 pm |
i got this message in the output indicator,
**Error** Scene=Scene 4, layer=Layer 93, frame=19:Line 4: Syntax error.
white star 3.onPress = function() {
**Error** Scene=Scene 4, layer=Layer 92, frame=19:Line 4: Syntax error.
white star 1.onPress = function() {
**Error** Scene=Scene 4, layer=Layer 91, frame=19:Line 4: Syntax error.
white star 2 c.onPress = function() {
Total ActionScript Errors: 3 Reported Errors: 3
any idea whats up with it?
cheers
gus
| | | | |
• • | | | |  | Re: flash sound problems by Gustav on Aug 16, 2006 at 8:36:49 pm |
it still doesnt work, when i click on the buttons, nothing happens, the sound file are named like;
UG_waterbeats.wav, should i rename it because of the _ ?
cant really think of anything else why it wouldnt work, does it matter if the same frame has a (stop) action on it?
Gus
| | | | |
• | | | |  | Re: flash sound problems by Matt Klundt on Aug 16, 2006 at 9:05:38 pm |
The stop action will not adversely affect the code on that page.
The name of the file should be fine. The main thing I suspect it could be is the Linkage identifier.
In your library right-click on the sound, then choose "Linkage..." Make sure that the Export For Actionscript checkbox is checked. Then, the name in the Identifier box is the name that should be inside quotes in the attachSound() function.
i.e.: sound1.attachSound("UG_waterbeats.wav");
Try that, if it doesn't work or you have already done that, read on..
Another possibility is that your buttons aren't named on the stage. A quick test would be to add inside of the onPress function a trace command. Such as:
whateverButton.onPress = function() {
trace(this._name+" pressed");
stopAllSounds();
sound1.start(0,999);
}
If no words pop up upon clicking on the button while testing, the names are not matching. It doesn't need to match the clip name in the library, but the name in the Properties box when you click on the button that is placed on the stage in that frame. Matt -------------------- http://www.mcquillendesign.comhttp://www.mattfoxgames.com
| | | | |
• | | | |  | Re: flash sound problems by Gustav on Aug 16, 2006 at 9:33:49 pm |
this is pretty intense now, i am pretty out of my depth, dont really know the first thing about actionscript,
I put in the code u gave me but i dont think i changed enough relevent things,
the following error message came up, and i am sure it is something really simple,
**Error** Scene=Scene 4, layer=Layer 93, frame=19:Line 9: Operator '=' must be followed by an operand
trace(this._name+" pressed");
**Error** Scene=Scene 4, layer=Layer 93, frame=19:Line 10: Unexpected '&' encountered
stopAllSounds();
**Error** Scene=Scene 4, layer=Layer 93, frame=19:Line 11: Unexpected '&' encountered
loop1.start(0,999);
Total ActionScript Errors: 3 Reported Errors: 3
i am pretty sure that the names of the buttons match up, when i click on the button on stage it comes up in the properties, and it seems the same,
I appreciate your help,
Gus
| | | | |
•
• | | | |  | Re: flash sound problems by Gustav on Aug 16, 2006 at 9:54:56 pm |
loop1 = new Sound();
loop1.attachSound("UG_waterbeats.wav");
whiteStar3.onPress = function() {
stopAllSounds();
loop1.start(0, 999);
}
loop2 = new Sound();
loop2.attachSound("UG_humm.wav");
whiteStar1.onPress = function() {
stopAllSounds();
loop2.start(0, 999);
}
loop3 = new Sound();
loop3.attachSound("UG_JAintro.wav");
whiteStar2c.onPress = function() {
stopAllSounds();
loop3.start(0,999);
}
| | | | |
• | | | |  | Re: flash sound problems by Matt Klundt on Aug 17, 2006 at 3:18:40 pm |
Try replacing the code with this, when the buttons are pressed while testing an output window should display the text within the trace(), if not, the problem is in the names:
loop1 = new Sound();
loop1.attachSound("UG_waterbeats.wav");
loop2 = new Sound();
loop2.attachSound("UG_humm.wav");
loop3 = new Sound();
loop3.attachSound("UG_JAintro.wav");
whiteStar3.onPress = function() {
trace("whiteStar3 pressed");
stopAllSounds();
loop1.start(0, 999);
}
whiteStar1.onPress = function() {
trace("whiteStar1 pressed");
stopAllSounds();
loop2.start(0, 999);
}
whiteStar2c.onPress = function() {
trace("whiteStar2c pressed");
stopAllSounds();
loop3.start(0,999);
} Matt -------------------- http://www.mcquillendesign.comhttp://www.mattfoxgames.com
| | | | |
• | | | |  | Re: flash sound problems by Gustav on Aug 17, 2006 at 3:53:37 pm |
i must be doing something wrong, I pasted the code in,
and it still doesnt play, the keyframe is white, would that do anything?
| | | | |
• • | | | |  | Re: flash sound problems by sherry conrads on Jan 19, 2010 at 8:23:54 am |
I have the same question. I have 62 different buttons that should play 62 different audio files. Problem is that the audio files overlap when two or more are clicked, rather than having previous audio files stop before the new sound plays. Can you tell me how you resolved Gus's problem? Thanks, Sherry
Sherry
| | | | |
| |
|