Link to home
Start Free TrialLog in
Avatar of chevronrod
chevronrodFlag for United States of America

asked on

How limit number of seconds a sound plays AS3?

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?
ASKER CERTIFIED SOLUTION
Avatar of Kim Walker
Kim Walker
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
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);

 
}
Avatar of chevronrod

ASKER

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....
then what xmediaman is what you're looking for.
can you give him feedback accordingly.