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

Click to play sound problem

Community Beginner ,
Oct 25, 2014 Oct 25, 2014

Hi, I am trying to play a sound file when the user clicks on a puzzle piece and drags it into place. I have the puzzle working and had the sound working in my prototype but when I built the final the sound isn't working. I used a code snippet to click to play/stop sound and I get the following error every time. Though the prototype still works and the code is exactly the same so I am wondering if there is some other problem I am not considering. For instance. I used MP3 in the prototype and WAV files in the final (but I did try a MP3 and that didn't play either - same error).

I would also like to block the user from clicking on another piece until the audio is done playing. It is an educational program and I would like them to hear each audio.

Any ideas? And thanks in advance for any help you can give.

Error #2044: Unhandled IOErrorEvent:. text=Error #2032: Stream Error.

  at C2GFinalInProgressDemo2_BuildaBody_fla::MainTimeline/fl_ClickToPlayStopSound_8()[C2GFinalInProgressDemo2_BuildaBody_fla.MainTimeline::frame171:190]

/* 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 ("").

*/

Digestive.addEventListener(MouseEvent.CLICK, fl_ClickToPlayStopSound_8);

var fl_SC_8:SoundChannel;

//This variable keeps track of whether you want to play or stop the sound

var fl_ToPlay_8:Boolean = true;

function fl_ClickToPlayStopSound_8(evt:MouseEvent):void

{

  if(fl_ToPlay_8)

  {

  var s:Sound = new Sound(new URLRequest("soundDigestive.wav"));

  fl_SC_8 = s.play();

  }

  else

  {

  fl_SC_8.stop();

  }

  fl_ToPlay_8 = !fl_ToPlay_8;

}

TOPICS
ActionScript
426
Translate
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 ,
Oct 26, 2014 Oct 26, 2014

you can't load and play a wave file without using a 3rd party library.

check org.as3wavsound.WavSound;

Translate
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 Beginner ,
Oct 26, 2014 Oct 26, 2014

Okay, thanks. I'll check that out. I tried changing it to an MP3 file and that didn't work either. But it worked in my prototype. Should it work with MP3?

Translate
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 ,
Oct 26, 2014 Oct 26, 2014
LATEST

yes.

Translate
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