Sound position and length on Slider Component AS3
Hello:
I have the following working great:
stop_btn.setStyle("icon", square_mc);
player_btn.setStyle("icon", next_mc);
import flash.events.Event
import flash.events.MouseEvent;
import flash.media.SoundTransform;
var alreadyDefined:Boolean;
volumen.value = 1;
if(!alreadyDefined){
alreadyDefined=true;
var isPlaying:Boolean = new Boolean();
var pausePosition:Number = new Number();
var soundClip:Sound = new Sound();
var sndChannel:SoundChannel;
soundClip.load(new URLRequest("audio/music.mp3"));
soundClip.addEventListener(Event.COMPLETE, onComplete, false, 0, true);
player_btn.addEventListener(MouseEvent.MOUSE_DOWN, btnPressController, false, 0, true);
stop_btn.addEventListener(MouseEvent.MOUSE_DOWN, btnPressStop, false, 0, true);
function onComplete(evt:Event):void {
sndChannel = soundClip.play();
isPlaying = true;
}
function btnPressController(evt:MouseEvent):void
{
switch(isPlaying)
{
case true:
//controller.text ="Sound Paused";
player_btn.setStyle("icon", pause_mc);
pausePosition = sndChannel.position;
sndChannel.stop();
isPlaying = false;
break;
case false:
//controller.text ="Sound Playing";
player_btn.setStyle("icon", next_mc);
sndChannel = soundClip.play(pausePosition);
isPlaying = true;
break;
}
}
function btnPressStop(evt:MouseEvent):void
{
pausePosition = 0;
sndChannel.stop();
//controller.text ="Play Sound";
player_btn.setStyle("icon", next_mc);
isPlaying = false;
}
}
volumen.addEventListener(Event.CHANGE, sliderChanged);
function sliderChanged(evt:Event):void {
var vol:Number = volumen.value;
volumen.liveDragging = true;
var st:SoundTransform = new SoundTransform(vol);
if(sndChannel != null){
sndChannel.soundTransform = st;
}
}
exit_btn.addEventListener(MouseEvent.CLICK, fexit);
function fexit(event:MouseEvent):void{
SoundMixer.stopAll();
Loader(this.parent).unloadAndStop();
}
I have another slider component on the movie with instance name PROGRESO
I would like for PROGRESOnto indicate (update) the sounds progress as it plays and be able to scrub through the sound.
Any idea how I can achieve this? Thanks for any help
