使用 ActionScript 3 声音淡入/淡出
我正在尝试在 Flash (CS5) 项目中淡入/淡出音乐。我将声音导入到库中,为“Export for ActionScript”设置一个类名,然后尝试使用 TweenLite/TweenMax 进行淡入淡出,如下所示:
var sound = new MySound();
sT = new SoundTransform(0.1);
sound.play(0,99999, c_sndEnvironment);
TweenLite.to(sound, 1, {volume: 1.0});
但它不起作用。我尝试在 TweenLite 上导入音量插件,但仍然没有任何结果。但我完全没有错误。
我做错了什么吗?
另外,有没有好的(完整的)AS3 音乐库?
谢谢。 :)
I am trying to make a fade in/out in a music in a Flash (CS5) project. I imported the sound to library, set a classname for "Export for ActionScript", and I was trying to fade with TweenLite/TweenMax, like this:
var sound = new MySound();
sT = new SoundTransform(0.1);
sound.play(0,99999, c_sndEnvironment);
TweenLite.to(sound, 1, {volume: 1.0});
But it just doesn't work. I tried to import the volume plugin on TweenLite, and still nothing. I got no error at all though.
Am I doing anything wrong?
Plus, is there any good (complete) AS3 library for music?
Thank you. :)
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
我为此使用 TweenMax,它非常简单
http://www.greensock.com/tweenmax/
I use TweenMax for this , it's pretty straightforward
http://www.greensock.com/tweenmax/
PatrickS 的说法是正确的,您应该调整 SoundChannel 的音量,而不是声音本身。 TweenMax 自动激活 VolumePlugin(以及其他几个),但您可以为 TweenLite 手动执行此操作,例如:
对于它的价值,您可能还想查看 LoaderMax,它具有 MP3Loader 类,可以更轻松地处理外部声音。它有自己的“体积”属性,您也可以对其进行补间。 http://www.greensock.com/loadermax/
PatrickS is correct about the fact that you should tween the volume of the SoundChannel, not the Sound itself. TweenMax automatically activates the VolumePlugin (along with several others), but you can do that manually for TweenLite like:
For what it's worth, you might also want to check out LoaderMax which has an MP3Loader class that makes working with external sounds easier. It has its own "volume" property that you can tween too. http://www.greensock.com/loadermax/
抱歉,我从这些代码行中发现了一种奇怪的行为。我的声音渐渐消失,悠悠球又回来了。声道与之前音量相同后,onComplete正常执行。有什么想法吗?
themeChannel = sndTheme.play(0, 99999);
TweenLite.from(themeChannel, 2, {volume:0,onComplete:stopTheme});
//编辑:我通过补间 SoundTransform 对象使其工作:
感谢:
http://www.zedia.net/2008/fading-out-音量使用-twenlite/
sorry, I kind kind of a strange behaviour from these lines of code. My sound fades out, and yoyos back. after the soundchannel is at the same volume as before, onComplete is executed normally. Any ideas?
themeChannel = sndTheme.play(0, 99999);
TweenLite.from(themeChannel, 2, {volume:0,onComplete:stopTheme});
//edit: I got it working by Tweening a SoundTransform Object:
thanks to:
http://www.zedia.net/2008/fading-out-volume-using-tweenlite/