In this tutorial, we will continue to work on the toggle button for the background music. When we created buttons in past tutorials, we first created the button layer and then "attached" actions to that button layer. For example, the Next button has a Go To Next Page action attached to it.

This time we will create the two actions for controlling the audio before we attach those actions to the button. Why? Because we are going to attach two actions to one button. Then we will tell the button to remember which action it performed last and when clicked again to perform the other action. This works like a light switch. If the light is off, you use the switch to turn the light on. If the light is on, you use the same switch to turn off the light. This is commonly called a toggle button.

Before we can set the toggle button, we need to create the two actions that will control the music.

Note: We have already set the audio to start playing when the app opens to the cover page.