I’ve got code that is triggered after a button press. This is the code:
function buttonHandler1( event )
timer.cancel( questionTimer )
display.remove( button1 )
button2.isActive = false
button3.isActive = false
button4.isActive = false
function replaceButton1( buttonBackground )
button1 = ui.newButton{
defaultSrc = buttonBackground,
defaultX = 260,
defaultY = 36,
overSrc = "button\_clicked.png",
overX = 260,
overY = 36,
id = "button1",
text = configuredButton1,
font = "Cantarell-Regular",
size = 14,
emboss = true,
isActive = false
}
button1.x = 160
button1.y = 295
end
function button1\_rightanswer()
replaceButton1( "button\_rightanswer.png" )
timer.performWithDelay(2000, setupCorrectAnswer, 1)
end
function button1\_wronganswer()
replaceButton1( "button\_wronganswer.png" )
timer.performWithDelay(2000, setupCorrectAnswer, 1)
end
if rightAnswer == 1 then
playSndRightAnswer = audio.play( sndRightAnswer, { oncomplete=button1\_rightanswer } )
else
playSndWrongAnswer = audio.play( sndWrongAnswer, { oncomplete=button1\_wronganswer } )
end
end
This code checks to see if a question was answered correctly or incorrectly, plays a sound, then is supposed to move on to the next function which recreates a button then moves on to the next function.
Testing in the simulator, the sound plays, but it never goes to either the button1_rightanswer() or button1_wronganswer() functions. It just stops after playing the sound.
I tried moving the button1_rightanswer() and button1_wronganswer() functions out of the buttonHandler1 function, but it does the same thing. Simulator does not report any errors. It just doesn’t move on to one of those two functions.
Am I coding something incorrectly here? I have the same type of code elsewhere and it does move on to the next function when the audio playback is complete.
If it makes a difference, I am using daily build 2012.721. Haven’t tried another build yet, but that is next on my list of things to check into.
Appreciate any insight here. [import]uid: 17827 topic_id: 20458 reply_id: 320458[/import]