拖放as3后禁用音频的问题
Problem disabling audio after dragging and dropping as3
我做了三张图片拉贴贴在另外三张上,成功了。
我想在附件被正确拉动并正确连接时添加一个加强声音,并且在操作不成功时另一个声音表示不满,
问题:Booster 在一次性成功后仍然适用于所有图像,并且失败声音不起作用。
也就是说,我无法正确地制定控制图书馆内部声音工作的符号。
请帮忙解决问题
代码中:
拉取图片名称(r1,r2,r3),静态图片名称(m1,m2,m3),成功音mus1,失败音mus2
////////////////
stop();
r1.addEventListener(MouseEvent.MOUSE_DOWN, fl_ClickToDrag);
function fl_ClickToDrag(event:MouseEvent):void
{
r1.startDrag();
}
stage.addEventListener(MouseEvent.MOUSE_UP, fl_ReleaseToDrop);
function fl_ReleaseToDrop(event:MouseEvent):void
{
r1.stopDrag();
if(r1.hitTestObject(m1))
{
r1.x=m1.x
r1.y=m1.y
}
else
{
r1.x=30.05
r1.y=155.95
}
}
r2.addEventListener(MouseEvent.MOUSE_DOWN, fl_ClickToDrag_2);
function fl_ClickToDrag_2(event:MouseEvent):void
{
r2.startDrag();
}
stage.addEventListener(MouseEvent.MOUSE_UP, fl_ReleaseToDrop_2);
function fl_ReleaseToDrop_2(event:MouseEvent):void
{
r2.stopDrag();
if(r2.hitTestObject(m2))
{
r2.x=m2.x
r2.y=m2.y
///////////////Sound code for reinforcement
var musAPlay:Ahsant = new Ahsant();
var musA1Channel:SoundChannel = new SoundChannel();
SoundMixer.stopAll();
musA1Channel.stop();
musA1Channel = musAPlay.play();
}
else
{
r2.x=30.05
r2.y=249.4
//////////////Sound code not being successful
var musBPlay:noah = new noah();
var musB1Channel:SoundChannel = new SoundChannel();
SoundMixer.stopAll();
musB1Channel.stop();
musB1Channel = musBPlay.play();
}
}
r3.addEventListener(MouseEvent.MOUSE_DOWN, fl_ClickToDrag_3);
function fl_ClickToDrag_3(event:MouseEvent):void
{
r3.startDrag();
}
stage.addEventListener(MouseEvent.MOUSE_UP, fl_ReleaseToDrop_3);
function fl_ReleaseToDrop_3(event:MouseEvent):void
{
r3.stopDrag();
if(r3.hitTestObject(m3))
{
r3.x=m3.x
r3.y=m3.y
}
else
{
r3.x=30.05
r3.y=347.4
}
if(r1.hitTestObject(m1)&& r2.hitTestObject(m2) && r3.hitTestObject(m3))
gotoAndPlay (5)
}
//////////////////////////
我可以通过用按钮名称替换舞台来解决问题,在成功提示音的代码之后,我输入以下内容:
button.removeEventListener(MouseEvent.MOUSE_DOWN, fl_ReleaseToDrop);
button.removeEventListener(MouseEvent.MOUSE_UP, fl_ReleaseToDrop);
其中按钮根据工作替换为自定义名称
我做了三张图片拉贴贴在另外三张上,成功了。 我想在附件被正确拉动并正确连接时添加一个加强声音,并且在操作不成功时另一个声音表示不满, 问题:Booster 在一次性成功后仍然适用于所有图像,并且失败声音不起作用。 也就是说,我无法正确地制定控制图书馆内部声音工作的符号。 请帮忙解决问题
代码中: 拉取图片名称(r1,r2,r3),静态图片名称(m1,m2,m3),成功音mus1,失败音mus2
////////////////
stop();
r1.addEventListener(MouseEvent.MOUSE_DOWN, fl_ClickToDrag);
function fl_ClickToDrag(event:MouseEvent):void
{
r1.startDrag();
}
stage.addEventListener(MouseEvent.MOUSE_UP, fl_ReleaseToDrop);
function fl_ReleaseToDrop(event:MouseEvent):void
{
r1.stopDrag();
if(r1.hitTestObject(m1))
{
r1.x=m1.x
r1.y=m1.y
}
else
{
r1.x=30.05
r1.y=155.95
}
}
r2.addEventListener(MouseEvent.MOUSE_DOWN, fl_ClickToDrag_2);
function fl_ClickToDrag_2(event:MouseEvent):void
{
r2.startDrag();
}
stage.addEventListener(MouseEvent.MOUSE_UP, fl_ReleaseToDrop_2);
function fl_ReleaseToDrop_2(event:MouseEvent):void
{
r2.stopDrag();
if(r2.hitTestObject(m2))
{
r2.x=m2.x
r2.y=m2.y
///////////////Sound code for reinforcement
var musAPlay:Ahsant = new Ahsant();
var musA1Channel:SoundChannel = new SoundChannel();
SoundMixer.stopAll();
musA1Channel.stop();
musA1Channel = musAPlay.play();
}
else
{
r2.x=30.05
r2.y=249.4
//////////////Sound code not being successful
var musBPlay:noah = new noah();
var musB1Channel:SoundChannel = new SoundChannel();
SoundMixer.stopAll();
musB1Channel.stop();
musB1Channel = musBPlay.play();
}
}
r3.addEventListener(MouseEvent.MOUSE_DOWN, fl_ClickToDrag_3);
function fl_ClickToDrag_3(event:MouseEvent):void
{
r3.startDrag();
}
stage.addEventListener(MouseEvent.MOUSE_UP, fl_ReleaseToDrop_3);
function fl_ReleaseToDrop_3(event:MouseEvent):void
{
r3.stopDrag();
if(r3.hitTestObject(m3))
{
r3.x=m3.x
r3.y=m3.y
}
else
{
r3.x=30.05
r3.y=347.4
}
if(r1.hitTestObject(m1)&& r2.hitTestObject(m2) && r3.hitTestObject(m3))
gotoAndPlay (5)
}
//////////////////////////
我可以通过用按钮名称替换舞台来解决问题,在成功提示音的代码之后,我输入以下内容: button.removeEventListener(MouseEvent.MOUSE_DOWN, fl_ReleaseToDrop); button.removeEventListener(MouseEvent.MOUSE_UP, fl_ReleaseToDrop);
其中按钮根据工作替换为自定义名称