Сценарий действия, чтобы добавить кнопку паузы на несколько кнопок аудио

В настоящее время я использую следующий код для воспроизведения аудиозаписей из библиотеки проекта.

import flash.media.Sound;
import flash.media.SoundChannel;
import flash.events.MouseEvent;

var sound1:Sound = new audio1();
var sound2:Sound = new audio2();

var mySoundChannel:SoundChannel = new SoundChannel();

function stopSound():void
{
   //This stops all sound in the sound channel. 
   //If there is nothing playing, nothing happens.
   mySoundChannel.stop();
}

//In this function, we create an argument that allows us to tell the function 
//what sound to we want it to play.
function playSound(soundname:String):void
{
   try
   {
      mySoundChannel = this[soundname].play(0, 0);
   }
   catch(error:ReferenceError)
   {
      trace("playSound: That sound name doesn't exist.");
      return;
   }
 }

//Hook up buttons-->
button1.buttonMode = true;
button1.useHandCursor = true;

button2.buttonMode = true;
button2.useHandCursor = true;

button1.addEventListener(MouseEvent.CLICK, button1click);
button2.addEventListener(MouseEvent.CLICK, button2click);

function button1click(evt:Event):void
{
   stopSound();
   playSound("sound1");
}

function button2click(evt:Event):void
{
   stopSound();
   playSound("sound2");
}

Мне нужно приостановить воспроизводимый в данный момент звук при нажатии кнопки. Как мне это сделать?

Ответы на вопрос(1)

Ваш ответ на вопрос