-
1. Re: Stop a sound at specific time
kglad Oct 30, 2014 12:30 PM (in response to Jhon Carlo)you can use the timer class:
var your_soundchannel:SoundChannel;
var t:Timer=new Timer(3000,1);
t.addEventListener(TimerEvent.TIMER,stopF);
function startF():void{
your_soundchannel=sound.play(2000);
t.start();
}
function stopF(e:TimerEvent):void{
your_soundchannel.stop();
}
-
2. Re: Stop a sound at specific time
Jhon Carlo Oct 30, 2014 1:23 PM (in response to kglad)thank you kglad for you courteous help!
I'm sorry because I forgot, in my previous post, to specify that I'm looking for different method from timer.
The user often click on button to start and stop audio and at my previuos experience I note that the timer goes out of sync.
I hope is there a different approach to this problem.
Is there?
Thank you again for the help.
-
3. Re: Stop a sound at specific time
kglad Oct 30, 2014 1:41 PM (in response to Jhon Carlo)the timer won't go out of sync. you must have some coding problem.
if you want the sound to stop a certain number of ms after it starts, use the code i suggested. if you want the sound to stop after a certain number of ms of play-time, and the user can stop and start the sound, use t.start() and t.stop() when the sound plays and when it stops, resp so the timer works as intended.
if that's confusing or that's not what you need, indicate the exact issue.
-
4. Re: Stop a sound at specific time
Jhon Carlo Oct 30, 2014 1:59 PM (in response to kglad)... yes is what I need.
I try to test again the timer method I hope It works.
Thank you again!
-
5. Re: Stop a sound at specific time
kglad Oct 30, 2014 4:03 PM (in response to Jhon Carlo)you're welcome.
if you have problems, copy and paste your sound code.
-
6. Re: Stop a sound at specific time
Jhon Carlo Nov 1, 2014 9:54 AM (in response to kglad)Hello kglad,
I tried this but doesn't work.
Why?
var mySound:Sound = new Sound();
mySound.load(new URLRequest("MyMp3.mp3"));
var myChannel:SoundChannel;
var t:Timer = new Timer(3000,1);
t.addEventListener(TimerEvent.TIMER,stopF);
function startF():void
{
myChannel = mySound.play(2000);
t.start();
}
function stopF(e:TimerEvent):void
{
myChannel.stop();
}
// Thank you.
-
7. Re: Stop a sound at specific time
kglad Nov 2, 2014 6:02 AM (in response to Jhon Carlo)nothing's calling startF



