Skip to main content
Participating Frequently
Jun 13, 2012 6:50 AM UTC
Question

Sounds don't play on iPhone

Good morning, I developed a simple soundboard as an .ipa app with AIR for iOS, but the sounds don't work. I mean, when I open the app I can see the buttons to push to play the relative sound, but when I push a button the sound doesn't play.

Here is my AS:

import flash.text.TextField;

//Array for buttons instances.

var buttonsArray:Array = new Array();

buttonsArray[0] = a01;

buttonsArray[1] = a02;

buttonsArray[2] = a03;

//Array for the sound clip names.

var soundArray:Array = new Array();

soundArray[0] = 'media/a01.mp3';

soundArray[1] = 'media/a02.mp3';

soundArray[2] = 'media/a03.mp3';

//This adds the mouse click event to the buttons.

for(var i:uint = 0; i < buttonsArray.length; i++){

buttonsArray.addEventListener(MouseEvent.CLICK, buttonClicked);

}

astop.addEventListener(MouseEvent.CLICK, stopButtonClicked);

//This function stops any sound clip that is playing and

//plays the sound file thats clicked.

function buttonClicked(e:MouseEvent):void{

SoundMixer.stopAll();

for(var i:uint = 0; i < buttonsArray.length; i++){

  if(e.target == buttonsArray){

   var s:Sound = new Sound();

   s.load(new URLRequest(soundArray));

   s.play();

  }

}

}

//This function adds a keyboard down event to the stage

//to stop a sound when the space bar is pressed.

function stopButtonClicked(e:MouseEvent):void{

SoundMixer.stopAll();

}

The same thing happens when I export this file as an .exe.

What am I missing?

This topic is closed to new replies. Start a new post to keep the conversation going.

12 replies

Inspiring
Jun 13, 2012 9:17 PM UTC

I know this may not be the answer you are looking for, but have you tried to include the sounds in the app via swc? I personally have never tried playing external sounds on iOS, but embeded sounds work just fine!

Translate
Participating Frequently
Jun 13, 2012 9:21 PM UTC

Sorry for the noob question, but can you explain the steps to do what you suggested?

Thanks in advance

Or just give me a link to a good tutorial...

Translate
Inspiring
Jun 13, 2012 9:28 PM UTC

Sure thing!

1. Create new FLA

2. Import the sounds you want to use into your library

3. Right click on the sounds in your library > Properties > Actionscript > Make sure to check "Export for Actionscript". (you can also rename the "Class" part to something easier to remember, just make sure you remember it) > Hit OK

4. File > Publish Settings > Now un-check  the "Flash (.swf)" option, and check the "SWC" option. Hit OK> then Publish.

You now will have a .swc file that you will include in the source of your project..

now the only thing left is to use the swc.

EX:

var mySound:Sound = new MyClassNameIRememberedFromBefore();

mySound.play();

Translate
Colin Holgate
Inspiring
Jun 13, 2012 12:15 PM UTC

Did you add the media folder in the General iOS settings?

Translate
Participating Frequently
Jun 13, 2012 12:39 PM UTC

Yes, but nothing happend: the sounds still don't play.

Translate