Animation
Posted: Sat Sep 08, 2018 9:43 pm
I am trying to play an animation (series of png's) that is correlated with a sound file. This works to play the sound file, and I can exit the animation and stop the sound from playing when gAnimation = "false". The animation continues after the sound is finished. What am I missing? I think this line is the problem: repeat until soundFinishedOnChannel, "current", tSoundFile Thanks!
on playAnimation
if gAnimation = "true" then
set the layerMode of card button "animeBtn" to "dynamic"
repeat with n = 1 to 2
put "robot_" & n into tName
set the icon of card button "animeBtn" to tName
wait 1 with messages
if gAnimation = "false" then exit playAnimation
end repeat
put specialFolderPath("engine") & "/audio/robotEffect.mp3" into tSoundFile
if the environment is "mobile" then mobilePlaySoundOnChannel tSoundFile, "current", "now"
repeat until soundFinishedOnChannel, "current", tSoundFile
repeat with n = 3 to 72
put "robot_" & n into tName
set the icon of card button "animeBtn" to tName
wait 1 with messages
if gAnimation = "false" then exit playAnimation
if soundFinishedOnChannel, "current", tSoundFile then exit repeat
end repeat
end repeat
end if
set the icon of card button "animeBtn" to 1485
set the icon of card button "SwitchButton" to 1140
set the layerMode of card button "animeBtn" to "static"
end playAnimation
on playAnimation
if gAnimation = "true" then
set the layerMode of card button "animeBtn" to "dynamic"
repeat with n = 1 to 2
put "robot_" & n into tName
set the icon of card button "animeBtn" to tName
wait 1 with messages
if gAnimation = "false" then exit playAnimation
end repeat
put specialFolderPath("engine") & "/audio/robotEffect.mp3" into tSoundFile
if the environment is "mobile" then mobilePlaySoundOnChannel tSoundFile, "current", "now"
repeat until soundFinishedOnChannel, "current", tSoundFile
repeat with n = 3 to 72
put "robot_" & n into tName
set the icon of card button "animeBtn" to tName
wait 1 with messages
if gAnimation = "false" then exit playAnimation
if soundFinishedOnChannel, "current", tSoundFile then exit repeat
end repeat
end repeat
end if
set the icon of card button "animeBtn" to 1485
set the icon of card button "SwitchButton" to 1140
set the layerMode of card button "animeBtn" to "static"
end playAnimation