private function VolumeSlider(){
soundVol = new SoundTransform();
trackBounds = track_mc.getBounds(track_mc);
xPos = trackBounds.x;
yPos = 0;//trackBounds.y;
widthPos = trackBounds.width-track_mc.slider_mc.width;
heightPos = 0;
bounds = new Rectangle(xPos,yPos,widthPos,heightPos);
track_mc.slider_mc.x = widthPos;
track_mc.mouseEnabled = false;
track_mc.slider_mc.buttonMode = true;
track_mc.slider_mc.addEventListener(MouseEvent.MOUSE_DOWN,dragSlider);
stage.addEventListener(MouseEvent.MOUSE_UP,stopSlider);
function dragSlider(event:MouseEvent):void {
event.target.startDrag(false,bounds);
addEventListener(Event.ENTER_FRAME,setVolume);
}
function stopSlider(event:MouseEvent):void {
track_mc.slider_mc.stopDrag();
removeEventListener(Event.ENTER_FRAME,setVolume);
}
function setVolume(event:Event):void {
trace(track_mc.slider_mc.x/widthPos);
ratio_volume = track_mc.slider_mc.x/widthPos;
soundVol.volume = ratio_volume;
revChan.soundTransform = soundVol;
revChan.soundTransform = soundVol;
}
|