Controlling audio playback
A SoundChannel
object is created for each sound that is played. Using the class' API, you can control the playback of a sound.
In this recipe, we will learn how to pause and resume a sound.
Getting ready
An .mp3
file and an FLA have been provided within the book's accompanying code bundle.
Open chapter12\recipe7\recipe.fla
into Flash Professional. Sitting in the center of the stage is a button named playBtn
. In the layer directly below is another button named pauseBtn
. During this recipe, we will write ActionScript to toggle between the two, indicating whether or not the MP3 is currently playing.
The MP3 we will be using can be found at chapter12\resources\music.mp3
. Before proceeding, copy it to the FLA's root folder at ...
Get Flash iOS Apps Cookbook now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.