比较用户的答案和数组中可能的答案

时间:2016-01-22 03:48:12

标签: actionscript-3 flash

我的输入文字字段有两个可能的答案,即" luah"或者" hal"但是我的代码无效:

stop();

//var jawapan1=Array;

txt_zuhal.addEventListener(KeyboardEvent.KEY_DOWN,handler);

function handler(event:KeyboardEvent)
{
    //jawapan1=("luah", "hal");

    // if the key is ENTER
    if(event.charCode == 13)
    {      
        if(txt_zuhal.text == 'luah'||'hal')
        {       
            trace("1.correct");
        }
        else
        {   
            trace("1.Sorry, Wrong answer");
        }
    }
}

1 个答案:

答案 0 :(得分:0)

    private function handler(event:KeyboardEvent):void
    {

        //jawapan1=("luah", "hal");

        // if the key is ENTER

        if(event.charCode == 13)
        {
            if(txt_zuhal.text == "luah" || txt_zuhal.text == "hal")
            {       
                trace("1.correct");
            }
            else
            {   
                trace("1.Sorry, Wrong answer");
            }
        }
    }