Flash 动作脚本3推出时停止声音

Flash 动作脚本3推出时停止声音,flash,actionscript-3,actionscript,flash-cs5,Flash,Actionscript 3,Actionscript,Flash Cs5,我正在尝试制作一个简单的交互式flash动画,当你滚动一个不可见的按钮时,会从库中播放一个声音,然后当你滚动时,声音停止 到目前为止,我有这个 import flash.events.Event; import flash.media.SoundChannel; stop(); button1.addEventListener(MouseEvent.ROLL_OVER,playSound); function playSound(event:Event) { var mySound:elmo

我正在尝试制作一个简单的交互式flash动画,当你滚动一个不可见的按钮时,会从库中播放一个声音,然后当你滚动时,声音停止

到目前为止,我有这个

import flash.events.Event;
import flash.media.SoundChannel;

stop();

button1.addEventListener(MouseEvent.ROLL_OVER,playSound);
function playSound(event:Event) {
var mySound:elmosample = new elmosample();
var myCahnnel:SoundChannel = mySound.play();
}`

有没有办法停止ROLL OUT播放的声音,或者在新声音开始播放时停止当前声音?

可能会在ROLL OUT上编写一个函数? 差不多

按钮1.添加事件列表器(MouseEvent.向外滚动,停止声音)

一次只播放一首歌 可能将声音变量名放入一个数组中 只使用一个频道? 但我不确定你是如何播放新的声音的 所以我不能给你一个明确的答案


希望这有帮助

我写了一个新的函数按钮2.addEventListener(MouseEvent.ROLL\u OUT,stopSound);函数stopSound(event:event){var mySound:elmosample1=new elmosample1();var myCahnnel:SoundChannel=mySound.stop();}但现在得到一个输出错误类型error:error#1006:stop不是函数。在佛罗里达州:MainTimeline/stopSound()您不能在AS3中使用sound类来停止声音使用其频道,所以请尝试MyChannel.stop();这似乎是一个很好的图坦卡蒙:
import flash.events.Event;
import flash.media.SoundChannel;

stop();

var mySound:Sound;
var myChannel:SoundChannel;

button1.addEventListener(MouseEvent.ROLL_OVER, onRollOver);
button1.addEventListener(MouseEvent.ROLL_OUT, onRollOut);   

function onRollOver(e:Event):void 
{
  //stop previous sounds
  if(myChannel)
    myChannel.stop();

  mySound = new elmosample();
  myChannel = mySound.play();
}

function onRollOut(e:Event):void
{
  myChannel.stop();
}