Copy link to clipboard
Copied
i and using Adobe Animate CC with Actionscript 3.0, I have vector graphics on the stage that I have converted to buttons and I want each button to be able to play seperate audio files on click and be able to pause the audio on the next click. I think the best way to do this is with Code Snippet PlayPause on click. But I keep getting errors in my code. Can y’all help me with this?
Hi.
According to the error, you're missing a right parentheses in line 21.
Please fix this first.
Copy link to clipboard
Copied
This is my code:
/* Click to Play/Stop Sound
Clicking on the symbol instance plays the specified sound.
Clicking on the symbol instance a second time stops the sound.
Instructions:
1. Replace "http://www.helpexamples.com/flash/sound/song1.mp3" below with the desired URL address of your sound file. Keep the quotation marks ("").
*/
man1_btn.addEventListener(MouseEvent.CLICK, fl_ClickToPlayStopSound);
var fl_SC:SoundChannel;
//This variable keeps track of whether you want to play or stop the sound
var fl_ToPlay:Boolean = true;
function fl_ClickToPlayStopSound(evt:MouseEvent):void
{
if(fl_ToPlay)
{
var s:Sound = new Sound(new URLRequest("http://Vanillathunder/interviews/dad--whitecollar.mp3"));
fl_SC = s.play();
}
else
{
fl_SC.stop();
}
fl_ToPlay = !fl_ToPlay;
}
Copy link to clipboard
Copied
Hi.
I just tested your code and it worked.
Can you show us the error you're getting?
Regards,
JC
Copy link to clipboard
Copied
Hey, thanks for taking a look at this. The error that gets thrown is:
location
scene 1. Layer ‘actions’ frame 1; line 21, column 98 1084, Syntex error, expecting rightparen before semicolon
i don’t know if my IRLrequest is correct for linking my sound in my external hard drive (i never really mess with coding) so the error might be coming from that
thanks for you help
chase
Copy link to clipboard
Copied
Hi.
According to the error, you're missing a right parentheses in line 21.
Please fix this first.