O'Reilly logo

ActionScript 3.0 Cookbook by Joey Lott, Darron Schall, Keith Peters

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Creating a Sound Application

Problem

You want to create a full-featured sound application, such as a streaming MP3 player.

Solution

Apply the other recipes in this chapter to play a streaming sound and add as many features as you want.

Discussion

This recipe combines many of the techniques shown throughout this chapter, integrated into a single application. There is much more that could be done with this, but it should give you a start at seeing how to use all these features together.

package { import flash.display.Sprite; import flash.display.Stage; import flash.display.StageAlign; import flash.display.StageScaleMode; import flash.text.TextField; import flash.events.Event; import flash.events.MouseEvent; import flash.events.TimerEvent; import flash.media.Sound; import flash.media.SoundChannel; import flash.media.SoundTransform; import flash.net.URLRequest; import flash.text.TextFormat; import flash.utils.Timer; public class CookBookPlayer extends Sprite { private var _channel:SoundChannel; private var _displayText:TextField; private var _sound:Sound; private var _panControl:PanControl; private var _playing:Boolean = false; private var _playPauseButton:Sprite; private var _position:int = 0; private var _spectrumGraph:SpectrumGraph; private var _volumeControl:VolumeControl; public function CookBookPlayer() { // Stage alignment stage.scaleMode = flash.display.StageScaleMode.NO_SCALE; stage.align = flash.display.StageAlign.TOP_LEFT; // Enter frame listener var timer:Timer = new Timer(20); ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required