• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
Exit
0

Can’t get code snippet PlayPause sound on click to work

New Here ,
Sep 25, 2018 Sep 25, 2018

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?

Views

244

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines

correct answers 1 Correct answer

Community Expert , Sep 26, 2018 Sep 26, 2018

Hi.

According to the error, you're missing a right parentheses in line 21.

Please fix this first.

Votes

Translate

Translate
New Here ,
Sep 25, 2018 Sep 25, 2018

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;

}

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Sep 25, 2018 Sep 25, 2018

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

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Sep 26, 2018 Sep 26, 2018

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

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Sep 26, 2018 Sep 26, 2018

Copy link to clipboard

Copied

LATEST

Hi.

According to the error, you're missing a right parentheses in line 21.

Please fix this first.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines