动作脚本 3 静音按钮
我有这个运行完美的动作脚本代码,但我尝试反转电影开始时没有任何声音的过程,然后当您单击按钮时,音乐将取消静音。
看来我不知道该怎么做。也许有人可以告诉我它是如何完成的,我真的对动作脚本一无所知 3
function setMute(vol){
var sTransform:SoundTransform = new SoundTransform(0,0);
sTransform.volume = vol; SoundMixer.soundTransform = sTransform;
}
var Mute:Boolean = false;
mutebutton.addEventListener
(MouseEvent.CLICK,toggleMuteBtn);
function toggleMuteBtn(event:Event){ if(Mute){ Mute = false; setMute(1);
mutte.gotoAndStop(1); }
else{ Mute = true;
setMute(0);
mutte.gotoAndStop(2); }
}
感谢您的帮助。
I have this action script code that is working perfectly but i am try to reverse the process where the movie starts without any sound, and then when you click the button the music will be unmuted.
It seems i can't figure out how to do this. Maybe some one can show me how it is done, i really know nothing about action script 3
function setMute(vol){
var sTransform:SoundTransform = new SoundTransform(0,0);
sTransform.volume = vol; SoundMixer.soundTransform = sTransform;
}
var Mute:Boolean = false;
mutebutton.addEventListener
(MouseEvent.CLICK,toggleMuteBtn);
function toggleMuteBtn(event:Event){ if(Mute){ Mute = false; setMute(1);
mutte.gotoAndStop(1); }
else{ Mute = true;
setMute(0);
mutte.gotoAndStop(2); }
}
Thanks for the help.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
更改
函数toggleMuteBtn(event:Event)
=>函数toggleMuteBtn(event:Event = NULL)
这允许您在不触发事件的情况下调用该函数。
toggleMuteBtn();
。应用程序启动时使用一次会将您的初始状态设置为静音而不是取消静音。Change
function toggleMuteBtn(event:Event)
=>function toggleMuteBtn(event:Event = NULL)
This allows you to call the function without triggering an Event.
toggleMuteBtn();
anywhere you need to mute/unmute. Using it once when the application starts will set your initial state to muted instead of unmuted.这是代码,因为它应该可以让电影以静音开始,然后当您单击按钮时声音将打开。
`
this is the code as it should be working to have movie start with muted sound and then when you click a button the sound will be turned on.
`