Actionscript 3 如何阻止歌曲在动作脚本3中播放
当用户单击按钮时,我试图阻止播放歌曲,这是我的代码:Actionscript 3 如何阻止歌曲在动作脚本3中播放,actionscript-3,adobe,flash-cs6,Actionscript 3,Adobe,Flash Cs6,当用户单击按钮时,我试图阻止播放歌曲,这是我的代码: var mySound:MainSound = new MainSound(); var cmyChannel :SoundChannel; animation_play.addEventListener(MouseEvent.CLICK, playSound); function playSound(event:Event) { mySound.play(); } animation_stop.addEventListener(Mou
var mySound:MainSound = new MainSound();
var cmyChannel :SoundChannel;
animation_play.addEventListener(MouseEvent.CLICK, playSound);
function playSound(event:Event) {
mySound.play();
}
animation_stop.addEventListener(MouseEvent.CLICK, stopSound);
function stopSound(event:Event) {
mySound.stop();
}
animation_play.addEventListener(MouseEvent.CLICK, fl_ClickToGoToAndPlayFromFrame_3);
function fl_ClickToGoToAndPlayFromFrame_3(event:MouseEvent):void
{
gotoAndPlay(2);
}
当我点击动画播放对象时,它工作得非常好,它通过播放声音和从指定帧开始动画来实现。然而,如果我点击动画停止对象,我会得到一个错误
TypeError: Error #1006: stop is not a function.
有人知道如何解决这个问题吗?要停止声音,必须使用如下SoundChannel对象,例如:
function playSound(event:Event): void
{
cmyChannel = mySound.play();
}
及
希望能有所帮助。要停止声音,必须使用如下SoundChannel对象,例如:
function playSound(event:Event): void
{
cmyChannel = mySound.play();
}
及
希望能有所帮助。您需要将mySound.play设置为cmyChannel对象。然后在CMY频道上呼叫stop。代码如下:
var mySound:MainSound = new MainSound();
var cmyChannel :SoundChannel;
animation_play.addEventListener(MouseEvent.CLICK, playSound);
function playSound(event:Event) {
cmyChannel = mySound.play();
}
animation_stop.addEventListener(MouseEvent.CLICK, stopSound);
function stopSound(event:Event) {
cmyChannel.stop();
}
animation_play.addEventListener(MouseEvent.CLICK, fl_ClickToGoToAndPlayFromFrame_3);
function fl_ClickToGoToAndPlayFromFrame_3(event:MouseEvent):void
{
gotoAndPlay(2);
}
您需要将mySound.play设置为cmyChannel对象。然后在CMY频道上呼叫stop。代码如下:
var mySound:MainSound = new MainSound();
var cmyChannel :SoundChannel;
animation_play.addEventListener(MouseEvent.CLICK, playSound);
function playSound(event:Event) {
cmyChannel = mySound.play();
}
animation_stop.addEventListener(MouseEvent.CLICK, stopSound);
function stopSound(event:Event) {
cmyChannel.stop();
}
animation_play.addEventListener(MouseEvent.CLICK, fl_ClickToGoToAndPlayFromFrame_3);
function fl_ClickToGoToAndPlayFromFrame_3(event:MouseEvent):void
{
gotoAndPlay(2);
}