/* Open a new FLash file (ActionScript 3.0). Select TimeLine --> Top Layer --> Frame 1 Select Window --> Actions (F9) Copy and paste this snippet Now we need 4 buttons. Well, actually they can be Movie Clips, Sprites - pretty much anything. The button class really doesn't help much. We need these instance names available to ActionScript play_btn stop_btn pause_btn up_btn down_btn We can get these by creating the shape with ActionScript, using flash or using tools Adobe provides: Component --> Video Common Libraries --> Buttons The book also has some great ones. Observe the output */ // All the variables are here. var soundReq:URLRequest = new URLRequest("free_fade.mp3"); var sound:Sound = new Sound(); var soundControl:SoundChannel = new SoundChannel(); var volumeControl:SoundTransform = new SoundTransform(); var resumeTime:Number = 0; sound.load(soundReq); // This listener fires whe the sound loader is complete sound.addEventListener(Event.COMPLETE, onComplete); // We could actually add these to the onComplete if we wanted. It's fine here too! up_btn.addEventListener(MouseEvent.CLICK, increaseVolume); down_btn.addEventListener(MouseEvent.CLICK, decreaseVolume); function onComplete(event:Event):void { play_btn.addEventListener(MouseEvent.CLICK, playSound); stop_btn.addEventListener(MouseEvent.CLICK, stopSound); } function playSound(event:MouseEvent):void { soundControl = sound.play(resumeTime); pause_btn.visible = true; pause_btn.addEventListener(MouseEvent.CLICK, pauseSound); play_btn.visible = false; play_btn.removeEventListener(MouseEvent.CLICK, playSound); } function pauseSound(event:MouseEvent):void { resumeTime = soundControl.position; soundControl.stop(); play_btn.visible = true; play_btn.addEventListener(MouseEvent.CLICK, playSound); pause_btn.visible = false; pause_btn.removeEventListener(MouseEvent.CLICK, pauseSound); } function stopSound(event:MouseEvent):void { soundControl.stop(); play_btn.visible = true; play_btn.addEventListener(MouseEvent.CLICK, playSound); pause_btn.visible = false; pause_btn.removeEventListener(MouseEvent.CLICK, pauseSound); } function increaseVolume(event:MouseEvent):void { volumeControl.volume += .5; soundControl.soundTransform = volumeControl; } function decreaseVolume(event:MouseEvent):void { volumeControl.volume -= .5; soundControl.soundTransform = volumeControl; } pause_btn.visible = false;