动作脚本:停止Adobe Flash CS4中的声音 [英] Actionscript: Stopping sound in Adobe Flash CS4

查看:266
本文介绍了动作脚本:停止Adobe Flash CS4中的声音的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想停止CS4中的特定声音而不同时停止所有声音.拥有一些我可以复制和粘贴的简单内容将是很棒的,因为我四处寻找这个问题的答案,并且得到了很多无法使用的巨型庞然大物. 谢谢!

I'd like to stop a specific sound in CS4 without stopping all of the sounds at the same time. It would be great to have something simple that I can copy and paste, as I've looked around a lot for an answer to this and gotten a lot of mumbo-jumbo that didn't end up working. Thanks!

推荐答案

您使用的是哪个版本的ActionScript,AS2还是AS3?

What version of actionscript are you using, AS2 or AS3?

您如何播放声音?它是否位于时间轴上的关键帧中?您是否正在使用动作脚本将其导入并从库中播放?

How are you playing your sound? Is it sitting in a keyframe on the timeline? Are you using actionscript to import it and play it from the library?

(使用时间轴代码进行编辑)

(Edit with timeline code)

好的,如果它在时间轴上,则需要使用动作脚本来播放它,以便以后可以单独定位它以停止它.

OK, if its on the timeline, you will need to use actionscript to play it, so that you can then later individually target it to stop it.

首先,转到您的音乐库,右键单击您的声音并编辑其属性.您想将其导出为动作脚本,并为其提供唯一的动作标识符,例如"MyGreatSound".没有空格等,只有一个字.

First, go to your library, right click on your sound and edit its properties. You want to export it for actionscript, and give it a unique actionscript identifier, something like 'MyGreatSound'. No spaces etc, just one word.

将声音从关键帧中移除.

Take your sound out of your keyframe.

接下来,在操作层中创建一个与声音开始相对应的关键帧,然后将其粘贴到其中; (这假设您在库中为声音指定了"MyGreatSound"的标识符)

Next, create a keyframe in your actions layer that corresponds to the start of your sound and paste this in; (this assumes you gave your sound in the library the identifier of 'MyGreatSound')

var myChannel:SoundChannel = new SoundChannel();
var mySound:Sound = new MyGreatSound(); 
myChannel = mySound.play(0);

将像以前一样播放您的声音.

That will play your sound, as before.

要停止播放,请创建另一个关键帧,该关键帧与时间线中您要停止声音的点相对应.

To stop it, create another keyframe that corresponds to the point in the timeline where you want the sound to stop.

粘贴以下内容;

myChannel.stop();

您可能会遇到范围问题,但请尝试一下.

You might get issues with scope, but give it a go.

此处有更多示例: http://www.republicofcode.com/tutorials/flash/as3sound/

这篇关于动作脚本:停止Adobe Flash CS4中的声音的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆