Copy link to clipboard
Copied
Hi All,
Forgive me if this is addressed elsewhere and kindly point me in the right direction. I am an infant with flash and action script so if you’re in doubt, error on the side of more specificity in your reply there's a lot of vocab I still don't know.
The Goal:
I have 4 audio files which are Soprano, Alto, Tenor, and Bass voices of one musical example. The result should allow the user to play all 4 voices at once and mute specific voices to hear all possible combinations of voices playing together or solo. I imagined a check box at the beginning of each notated musical line that mutes that voice when checked.
It would be ideal to have Play, Pause, and Stop playback options where ‘Stop’ resets playback to the beginning and ‘Pause’ maintains the current place in time and resumes from that point once playback is initiated again.
I am able to get single sound files to play from one button, but I’m struggling to find how to link multiple audio files to start at the same time from one button. I found this link: https://forums.adobe.com/thread/1069107?start=0&tstart=0
where the last post mentions using arrays, but being a complete beginner I don’t completely understand what they do.
I know it’s a big chunk of questions all at once but if you could address any portion of it, or direct me to a tutorial/instructions, I’d really appreciate it.
Thank you for taking the time to help others ![]()
use:
...
kglad wrote:
use:
import flash.events.MouseEvent;
import flash.media.SoundTransform;
var soprano: Sound = new Soprano();
var alto: Sound = new Alto();
var tenor: Sound = new Tenor();
var bass: Sound = new Bass();
var soundA: Array = [soprano, alto, tenor, bass];
var offsetA:Array = []
var st: SoundTransform = new SoundTransform();;
play_btn.addEventListener(MouseEvent.CLICK, playF);
pause_btn.addEventListener(MouseEvent.CLICK, pauseF);
stop_btn.addEventListener(MouseEvent.CLICK, stop
Copy link to clipboard
Copied
Thank you.
1. Play and Stop work. Pause will stop all audio but will not resume from the point it was paused. Is there a way to have one button that will both pause and resume playback from the paused location.
2. This may be a similar principle. I made two more buttons: one for mute and one for unmute.
-They worked but only muted and unmuted the Soprano Voice
-Am I able to have one button for each voice that will both mute and unmute each individual voice?
I think a check box may be more appropriate to visually reflect whether or not a voice is currently being played.
Would that could look something like the following for a checkbox called mute_Scb, mute_Acb, etc:
mute_Scb.addEventListener(MouseEvent.CLICK, muteS);
function mute_Scb (event:MouseEvent) :void{
if(mute_Scb ==true) //???????//
else( //???????// )
}
Copy link to clipboard
Copied
are you using an unpause button to call unpauseF?
Copy link to clipboard
Copied
I created a button called unpauseF and it works. Will just have to keep 2 separate buttons? One for "pause" and another for "unpause?"
Copy link to clipboard
Copied
you couild use one button if you want by using a toggle boolean or something else to alternately call pauseF and unpauseF.
(p.s when using the adobe forums, please mark helpful/correct responses, if there are any.)
Copy link to clipboard
Copied
Do you have any advice for getting the the other voices to mute individually?
From your answer 24 above, all works well except the mute functions.
If I create a mute button called "muteF" and another (unmute) button called "unmuteF" Those buttons will only mute and unmute the soprano voice.
I found tutorials on how to mute 1 audio file elsewhere online but none that show script for muting individual audio files from within an array. The end result should allow the user to hear all possible combinations of voices playing together by muting and unmuting them, which is why I think a check box may be better for the visual confirmation of which voices would be currently muted at any given point.
Copy link to clipboard
Copied
yes, i included code for that.
if you want to mute a voice call, muteF and pass the appropriate index. for example, if you want to mute bass, use:
muteF(3);
// or
muteF(soundA.indexOf(bass));
Copy link to clipboard
Copied
With respect to the mute buttons for specific voices...
What identifier did I miss and where should it go in the following code?
mute_b.addEventListener(MouseEvent.CLICK, muteF);
function muteF(3)(i:int):void{
st.volume = 0;
this['sc_'+i].soundTransform = st;
}
// gives me compiler error:
| Scene 1, Layer 'scripts', Frame 1, Line 58 | 1084: Syntax error: expecting identifier before 3. |
And
function muteF(soundA.indexOf(bass))(i:int):void{
st.volume = 0;
this['sc_'+i].soundTransform = st;
}
//gives me compiler errors:
| Scene 1, Layer 'scripts', Frame 1, Line 58 | 1084: Syntax error: expecting rightparen before dot. |
| Scene 1, Layer 'scripts', Frame 1, Line 58 | 1158: Syntax error: missing left brace ({) before the function body. |
I tried putting in rightpren and left brace in different places but it just creates more errors. Line 58 is: "function muteF(...etc"
Copy link to clipboard
Copied
if mute_b is supposed to mute the bass sound, use:
mute_b.addEventListener(MouseEvent.CLICK, mute_bF);
function mute_bF():void{
st.volume = 0;
this['sc_'+3].soundTransform = st;
}
Copy link to clipboard
Copied
When I test the file. I the bass will not mute and I get this output:
ArgumentError: Error #1063: Argument count mismatch on AEhelp2_fla::MainTimeline/mute_bF(). Expected 0, got 1.
Copy link to clipboard
Copied
use:
mute_b.addEventListener(MouseEvent.CLICK, mute_bF);
function mute_bF(e:MouseEvent):void{
st.volume = 0;
this['sc_'+3].soundTransform = st;
}
Get ready! An upgraded Adobe Community experience is coming in January.
Learn more