Dear all i had made a knob which circulate on onmousedown event
if the knob is circulate between the angle 0[SUP]0 [/SUP]to 180[SUP]0[/SUP] the soundclip_1.mp3 is played and if the knob is rotated between -180[SUP]0 [/SUP]to -1[SUP]0 [/SUP]then soundclip_2.mp3 is played wihich is fine .
the problem is that when we rotate the knob the previous soundclip do not stop and is played along with the new soundclip loaded on mousedown event. the soundclip are added as we click on the knob.
can some plz help me out
import flash.media.SoundTransform;
import flash.media.Sound;
tune_mc.addEventListener(MouseEvent.MOUSE_DOWN,tune_turn);
stage.addEventListener(MouseEvent.MOUSE_UP,tune_endTurn );
function tune_turn(e:Event):void
{
stage.addEventListener(MouseEvent.MOUSE_MOVE,tune_turn);
var tune_position:Number = Math.atan2(mouseY - tune_mc.y,mouseX - tune_mc.x);
var tune_angle:Number = (tune_position/Math.PI) * 180;
tune_mc.rotation = tune_angle;
song_select(tune_angle);
}
function tune_endTurn(e:MouseEvent):void
{
tune_mc.removeEventListener(MouseEvent.MOUSE_DOWN, tune_turn);
stage.removeEventListener(MouseEvent.MOUSE_MOVE,tune_turn);
tune_mc.addEventListener(MouseEvent.MOUSE_DOWN,tune_turn);
}
function song_select(tune_angle:Number):void{
if (tune_angle >= 1 && tune_angle <= 180){
var soundFile:URLRequest = new URLRequest("soundclip_1.mp3..mp3");
var song:Sound = new Sound();
var mySoundChannel:SoundChannel = new SoundChannel();
song.load(soundFile);
mySoundChannel = song.play();
}
else if(tune_angle >= -180 && tune_angle <= -1) {
var soundFile1:URLRequest = new URLRequest("soundclip_2.mp3..mp3");
var song1:Sound = new Sound();
var mySoundChannel_1:SoundChannel = new SoundChannel();
song1.load(soundFile1);
mySoundChannel_1 = song1.play();
}
/*mySoundChannel.stop();
mySoundChannel_1.stop();*/
}