动作脚本 3 静音按钮

发布于 2025-01-05 11:36:37 字数 545 浏览 6 评论 0原文

我有这个运行完美的动作脚本代码,但我尝试反转电影开始时没有任何声音的过程,然后当您单击按钮时,音乐将取消静音。

看来我不知道该怎么做。也许有人可以告诉我它是如何完成的,我真的对动作脚本一无所知 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

风吹过旳痕迹 2025-01-12 11:36:37
  1. 更改函数toggleMuteBtn(event:Event) =>

    函数toggleMuteBtn(event:Event = NULL)

    这允许您在不触发事件的情况下调用该函数。

  2. 在需要静音/取消静音的任何地方使用 toggleMuteBtn();。应用程序启动时使用一次会将您的初始状态设置为静音而不是取消静音。
  1. Change function toggleMuteBtn(event:Event) =>

    function toggleMuteBtn(event:Event = NULL)

    This allows you to call the function without triggering an Event.

  2. Use toggleMuteBtn(); anywhere you need to mute/unmute. Using it once when the application starts will set your initial state to muted instead of unmuted.
彻夜缠绵 2025-01-12 11:36:37

这是代码,因为它应该可以让电影以静音开始,然后当您单击按钮时声音将打开。

var mute:Boolean = false;
var st:SoundTransform;// <- variable is exposed to all functions in this script

mutebutton.addEventListener(MouseEvent.CLICK,toggleMuteBtn);

function toggleMuteBtn(event:Event = null)
{
    if (mute)
    {
        setMute(1,1);
    }
    else
    {
        setMute(0,2);
    }
    // toggle the mute Boolean
    mute = !mute;
}

function setMute(vol:Number, frm:Number):void
{
    st = new SoundTransform(0,0);
    st.volume = vol;
    SoundMixer.soundTransform = st;
    mutte.gotoAndStop(frm);
}
toggleMuteBtn();

`

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.

var mute:Boolean = false;
var st:SoundTransform;// <- variable is exposed to all functions in this script

mutebutton.addEventListener(MouseEvent.CLICK,toggleMuteBtn);

function toggleMuteBtn(event:Event = null)
{
    if (mute)
    {
        setMute(1,1);
    }
    else
    {
        setMute(0,2);
    }
    // toggle the mute Boolean
    mute = !mute;
}

function setMute(vol:Number, frm:Number):void
{
    st = new SoundTransform(0,0);
    st.volume = vol;
    SoundMixer.soundTransform = st;
    mutte.gotoAndStop(frm);
}
toggleMuteBtn();

`

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文