Toggle event sounds on and off

I read that there is no api functionality to turn event sounds on and off and was trying to figure out an alternative solution.

Here is what I have come up with using a global variable gSoundOn. Not an ideal solution as involves more if statements in my game action code so if anyone has a more optimised solution I would love to see it.

  
-- BallsAppearSound Sound  
  
 local ballsAppearSoundID = media.newEventSound( "audio/bbSwoosh.caf" )  
  
 local playBallsAppearSound = function()  
  
 if gSoundOn == true then  
  
 media.playEventSound( ballsAppearSoundID )  
  
 end  
 end  
  

[import]uid: 7863 topic_id: 3267 reply_id: 303267[/import]