【问题标题】:Disable 2 buttons in flash after so many button clicks在点击了这么多按钮后,在 Flash 中禁用 2 个按钮
【发布时间】:2014-01-28 10:00:25
【问题描述】:

我正在用 Flash 制作文字游戏,我希望能够在按钮计数达到某个值后禁用 2 个按钮,但我制作的代码在单击一次后就禁用了该按钮。我已经为其他语言编写了与此类似的代码,所以我认为使用相同的基本语法不会太难。我是否可能需要纠正一个 for 循环,或者我只是在这个 if 语句中犯了一个基本错误

on (release){
var i;

if(i >= 6)
{
    vowel.enabled = false;
    cons.enabled = false;
}   

i++;
}

【问题讨论】:

    标签: flash actionscript


    【解决方案1】:

    也许你应该像这样使用按钮索引值

    on (release){
    
    // somewhere you have to set index values your vowel and cons buttons 
    // notice that you shouldn't set these index on(release) function. You should set button index values global scope.
    
    vowel.index = 0;
    const.index = 1;
    
    if(this.i >= 6)
    {
        if(i != vowel.index && i != cons.index) {
            // enable other buttons this condition ignores vowel and cons buttons.
        }
        vowel.enabled = false;
        cons.enabled = false;
    }   
    
       this.i++;
    }
    

    【讨论】:

    • 顺便说一句,“const”是actionscript中的保留变量。我建议您更改“constBtn”或其他名称...
    猜你喜欢
    • 2020-10-27
    • 2012-07-06
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2019-10-08
    相关资源
    最近更新 更多