I am trying to create an ebook. I want a certain sound to play in scene 2 and when i click on the nextPage button I have i want to get rid of that audio so that it no longer plays in scene 3. Where do I need to put audio.dispose and do I need to place audio.stop in my code before I dispose of the sound? I tried to put audio.dispose in the nextPg:tap(e) function below but when I tapped the nextPage button it just caused the audio to “skip” in scene 3. Any help would be greatly appreciated, thank you!
local storyboard = require(“storyboard”);
local scene = storyboard.newScene()
mySong = audio.play(backgroundSound, {channel=1, loops=-1, fadein=3000} )
local nextPg;
function scene:createScene(e)
local view = self.view
local background = display.newImage( “cover2.png” );
nextPg = display.newImage( “nextPage.png” );
nextPg.x = 949
nextPg.y = 53
function nextPg:tap(e)
storyboard.gotoScene(“scene3”,{
effect = “slideLeft”, – transition effect to implement
time = 250 – duration of the transition effect in milliseconds
});
end
nextPg:addEventListener(“tap”,nextPg);
view:insert(background);
view:insert(nextPg);
end
function scene:enterScene(e)
end
function scene:exitScene(e)
storyboard.purgeScene(“scene2”);
end
scene:addEventListener(“createScene”, scene);
scene:addEventListener(“enterScene”, scene);
scene:addEventListener(“exitScene”, scene);
return scene [import]uid: 146168 topic_id: 30620 reply_id: 330620[/import]