How can I add sound to SlideView lesson?

Hi every one,

can any one help me in this. I want to add sound to this example:

http://developer.anscamobile.com/content/slide-view

I mean when I touch any of these pictures a sound file will run, in other words when I touch picture1 a sound file will run, and when I touch picture2 another sound file will run. I have tried this line of code:

sound_1 = audio.loadSound(“file1.mp3”)
sound_2 = audio.loadSound(“file2.mp3”)

theGroupName[1] = audio.play(sound_1)
theGroupName[2] = audio.play(sound_2)

it does work, but I have to click the picture twice and when I transfer it to the iPod it doesn’t work properly.

TIA;

admin6 [import]uid: 45018 topic_id: 8632 reply_id: 308632[/import]

did u setup an event listener for each image?

c. [import]uid: 24 topic_id: 8632 reply_id: 31019[/import]

Dear Carlos,

Yes, I have tried this function:


function soundFunction (i, soundFile)
local touchedA = function (event)
if event.phase == “ended” then
media.playEventSound(“media/”…soundFile…".mp3");
end
end
slideGroup[i]:addEventListener( “touch”, touchedA);
end

local aSound = soundFunction(2, “aSound”);

in the simulator there is no problem, I can hear the sound when I click the pic twice. But still there is a problem when I install the app in the device. Sometimes the program crushes or just repeat the first sound file again and again and then crushes.

is there a problem if I use 50 pictures along with a sound file for each?

Thanks in advance [import]uid: 45018 topic_id: 8632 reply_id: 31789[/import]