// Richard Caceres, rcaceres {at} ucla.edu // DMA 199 // $Id: BoxSprite.as,v 381.1 2008-02-07 01:06:53-08 - - $ // $Date: 2008-02-07 01:06:53-08 $ package { import flash.display.*; import flash.events.*; import flash.media.Sound; import flash.media.SoundChannel; class BoxSprite extends Sprite { public var snd; public var snd_chnl; public var gfxscaler = 1; public function BoxSprite (snd:Sound) { this.snd = snd; addEventListener (MouseEvent.ROLL_OVER, handleRollOver); } public function update () { if (snd_chnl) { //trace ("snd_chnl:"+snd_chnl); gfxscaler = 1 + snd_chnl.leftPeak } else { gfxscaler = 1; } } public function draw_ () { graphics.clear(); graphics.beginFill(0xF2EA5B); graphics.drawRect(0, 0, 30 * gfxscaler , 100 * gfxscaler); graphics.endFill(); } public function handleRollOver (e:MouseEvent) { //trace (e); snd_chnl = snd.play(); snd_chnl.addEventListener (Event.SOUND_COMPLETE, soundCompleteHandler); } public function soundCompleteHandler (e:Event) { //trace (e); } } }