Is it possible?. I am quite new to ActionScript 3 & have been playing around with the slider component. I have set a slider with images,and set a sound to play, so if the value is greater than 0 it would play and if it is greater than 4 it would stop. yet when I export it and it comes up with no errors. I am sure I have to change change the event.value’s to something else rather than numbers. or rather use another event but I am not sure..so I would presume the mp3 would keep playing if you side between those images, not restart on each value it hits. This is what I have
function changeHandler(event:SliderEvent):void {
aLoader.source = "pic"+event.value+".jpeg";
}
function music(event:SliderEvent):void {
var mySound:Sound = new tes1();
var myChannel:SoundChannel = new SoundChannel();
mySound.load(new URLRequest("tes1.mp3"));
if (event.value > 0 || event.value > 4 ){
myChannel = mySound.play();
}
else{
myChannel.stop();
}
}
You are creating a new sound channel at every slider event and, if the value is outside the desired range, stopping that new sound channel. But it wasn’t playing any sound to start with.
What you probably want is to store the sound channel outside the event handler, and maybe not replay the sound when the value jumps within the range:
So when the value gets outside the desired range, it stops playing the last sound, and when the value moves within the range, it just continues playing instead of restarting.