Question
slider volume
Hello. I need a little help with a volume slider. when the music is playing, the slider does not work. When the music starts it does work, but once it starts playing, even if you move it, it doesn't work. Thank you very much, and this is the code:
package com.kglad {
import flash.display.MovieClip;
import flash.display.InteractiveObject;
import flash.events.Event;
import flash.events.MouseEvent;
import flash.display.MovieClip;
import flash.media.Sound;
import flash.media.SoundMixer;
import flash.media.SoundChannel;
import flash.media.SoundTransform;
import flash.geom.Rectangle;
public class Standars_all_mc extends MovieClip {
private var clave_sp:SoundChannel
private var viola_sp:SoundChannel;
private var st:SoundTransform
private var clave_sound:Sound;
private var tiorba_sound:Sound;
private var viola_sound:Sound;
private var soundA:Array = ["clave_sound","viola_sound"];
private var i:int;
private var default_tempo:Number = 1.0;
private var backE:Event = new Event("backE");
private var simple_playerA:Array = ["clave_sp","viola_sp"];
private var instrumentsA:Array = ["clave_mc","viola_mc"];
public function Standars_all_mc() {
this.addEventListener(Event.ADDED_TO_STAGE,addedF);
//this.addEventListener(Event.REMOVED_FROM_STAGE,removedF)
}
private function addedF(e:Event):void{
if(!back_mc.hasEventListener(MouseEvent.MOUSE_DOWN)){
back_mc.addEventListener(MouseEvent.MOUSE_DOWN,backF);
playStop_mc.addEventListener(MouseEvent.MOUSE_DOWN,play_stopF);
playStop_mc.gotoAndStop(1);
for(i=0;i<instrumentsA.length;i++){
this[instrumentsA[i]].addEventListener(MouseEvent.MOUSE_DOWN,instrumentF);
}
volume_mc.knob_mc.addEventListener (MouseEvent.MOUSE_DOWN, volume_drag);
volume_mc.knob_mc.addEventListener (MouseEvent.MOUSE_UP, volume_dragStop);
volume_mc.knob_mc.addEventListener (MouseEvent.MOUSE_OUT, volume_dragStop);
volume_mc.knob_mc.addEventListener (Event.ENTER_FRAME, volume_set);
}
default_settingsF();
}
private function play_stopF(e:MouseEvent):void{
if(e.currentTarget.currentFrame==1){
e.currentTarget.gotoAndStop(2);
playF();
} else {
e.currentTarget.gotoAndStop(1);
stopF();
enableF(speed_control, true);
enableF(viola_mc, true);
enableF(clave_mc, true);
}
}
private function playF():void{
for(i=0;i<instrumentsA.length;i++){
if(this[instrumentsA[i]].currentFrame==1){
this[soundA[0]] = new xacara_clave_2();
this[soundA[1]] = new xacara_viola_2();
this[simple_playerA[i]]=this[soundA[i]].play(0,2);
this[simple_playerA[i]].soundTransform = st;
}
}
}
private function stopF():void{
SoundMixer.stopAll();
}
private function instrumentF(e:MouseEvent):void{
if(e.currentTarget.currentFrame==1){
e.currentTarget.gotoAndStop(2);
}
else {
e.currentTarget.gotoAndStop(1);
}
}
function volume_drag(evt:MouseEvent):void{
volume_mc.knob_mc.startDrag(false, new Rectangle(0,0,volume_mc.line_mc.width-volume_mc.knob_mc.width,0));//se atrastra en esos valores
}
function volume_dragStop(evt:MouseEvent):void{
volume_mc.knob_mc.stopDrag();
}
function volume_set(evt:Event):void{
var vol:Number=volume_mc.knob_mc.x /100;
st = new SoundTransform(vol);
}
