We help IT Professionals succeed at work.

How limit number of seconds a sound plays AS3?

chevronrod asked
I know how to play a sound and how to loop it and how to start it something later than the beginning of the sound.

But how can you tell a 10-second (for example) sound clip to just play 6 seconds from the beginning, or 8 seconds, or whatever?
Watch Question

Web Programmer/Technician
The only way I know would be to play your sound into a sound channel and set a timer to stop the sound channel. Look at Stopping a Sound about 1/3 down the page.
Top Expert 2009

If i understand you correctly what you're looking for is the offset, not to wait x seconds before you play a sound, but rather start a sound x  seconds in.

//include all your imports and declare your variables as required, then

var offsetTime:Number = 3;
function playSound(e:MouseEvent):void
  channel1 = mySound.play(offsetTime);



Actually, I'm not looking for the offset. I'm wanting to play it from the very beginning. But the sound file is 8 seconds long. I want it to stop at 5 seconds....
Top Expert 2009

then what xmediaman is what you're looking for.
can you give him feedback accordingly.