Hi
I’m updating my app for the first time in 3 years. However, something has stopped working that was working before. My app is about music theory and one thing it does is play scales up and down. There’s a play button that the user taps, and then the scale plays. While it plays, the listeners on the play button and advance-to-next-screen button are removed, but once the scale is done playing the listeners is supposed to be added back. This still works properly on my 3 year old version on the app store. However, using the latest Corona simulator and a new Macbook running OS 14.2, the audio.play function’s onComplete is never called (without my making any code changes) which means the listener doesn’t get added back to the buttons once the scale is over. This is the listener function for my play button. Any help appreciated. Thanks in advance.
hearButtonListener = function(event)
if ( event.phase == "began" ) then
display.getCurrentStage():setFocus(event.target)
elseif ( event.phase == "ended" ) then
display.getCurrentStage():setFocus(nil)
if (scaleData.areWeEvaluating == true) then
scaleData.nextButtonBG:removeEventListener("touch",nextButtonListener)
scaleData.nextButtonBG.alpha = 0.5
end
commonData.hearButton:removeEventListener("touch",hearButtonListener)
commonData.hearButton.alpha = 0.5
local up = true
local i = 1
local channelCounter = 1
local iterations = 0
local function areWeDone(event) -- HAS THE SCALE HAS FINISHED PLAYING?
if event.channel == iterations then -- put back the next button listener
commonData.hearButton:addEventListener("touch",hearButtonListener)
commonData.hearButton.alpha = 1
if (scaleData.areWeEvaluating == true) then
scaleData.nextButtonBG:addEventListener("touch",nextButtonListener)
scaleData.nextButtonBG.alpha = 1
end
end
end -- end of inner function areWeDone
local playSounds = function(event)
if up == true then
audio.play(scaleData.soundArray[i],{channel = channelCounter, onComplete = areWeDone})
i = i + 1
if i == #scaleData.soundArray then up = false end
elseif up == false then
audio.play(scaleData.soundArray[i],{channel = channelCounter,
onComplete = areWeDone} )
i = i - 1
end
channelCounter = channelCounter + 1
end
if scaleData.scaleArray[scaleData.scaleNumber][5] == "melodic minor" then
iterations = 15
else iterations = (#scaleData.soundArray * 2) - 1
end
scaleData.theTimer = timer.performWithDelay(250,playSounds,iterations)
scaleData.timerTable[scaleData.timerIndex] = scaleData.theTimer
scaleData.timerIndex = scaleData.timerIndex + 1
end
end