The ability to generate some sort of visual feedback when playing audio is very useful to the user, as they will be able to see that playback occurs even if the device volume has been muted or turned down. Generating visuals from audio is also useful in certain games, or in monitoring audio input levels.
We will load a MP3
file into a Sound
object. By employing the SoundMixer. computeSpectrum()
method, we can access the actual bytes being played back and construct visualizations with this data using the Sprite graphics
API:
1. First, import the following classes into your project:
import flash.display.Sprite; import flash.display.StageAlign; import flash.display.StageScaleMode; import flash.events.TimerEvent; import flash.media.Sound; import flash.media.SoundChannel; import flash.media.SoundMixer; import flash.net.URLRequest; import flash.ui.Multitouch; import flash.ui.MultitouchInputMode; import flash.utils.ByteArray; import flash.utils...