AS3 - 使用ComboBox进行真/假测验

时间:2018-01-20 23:26:36

标签: actionscript-3 flash

所以我一段时间以来一直在研究一个更大的项目,并且对我正在融入其中的测验感到有些困惑。

我想使用ComboBoxes来创建一个真/假测验。我将使用开关结构来跟踪最终用户的答案。我现在已经知道如何使用ComboBoxes的开关结构,但是,我不确定如何:

1.)确定组合框中的所有标签是否正确,并且; 2.)我如何让我的结构变得有效。我现在遇到了麻烦。

请参阅下面的代码。您将看到这是一个逻辑错误。我不确定问题是什么,所以再次感谢您的帮助!

谢谢!

-Zero;

import fl.controls.ComboBox;
import flash.events.MouseEvent;

F21next_btn.visible=false; 

firstTF_cb.addItem({label: "True"}); 
firstTF_cb.addItem({label: "False"}); 
secondTF_cb.addItem({label: "True"}); 
secondTF_cb.addItem({label: "False"}); 
thirdTF_cb.addItem({label: "True"}); 
thirdTF_cb.addItem({label: "False"}); 
fourthTF_cb.addItem({label: "True"}); 
fourthTF_cb.addItem({label: "False"}); 
fifthTF_cb.addItem({label: "True"}); 
fifthTF_cb.addItem({label: "False"}); 

F21check_btn.addEventListener(MouseEvent.CLICK, F21checkAnswers); 
F21next_btn.addEventListener(MouseEvent.CLICK, F21goToFrameTwentytwo); 

var firstCB:ComboBox; 
var secondCB:ComboBox; 
var thirdCB:ComboBox; 
var fourthCB:ComboBox; 
var fifthCB:ComboBox; 

firstCB=firstTF_cb; 
secondCB=secondTF_cb; 
thirdCB=thirdTF_cb; 
fourthCB=fourthTF_cb; 
fifthCB=fifthTF_cb; 

function F21goToFrameTwentytwo(event:MouseEvent):void{
    gotoAndStop(22); 
}

//HOW DO U CHECK IF A COMBO BOX ITEM IS TRUE/FALSE AND SELECTED 
function F21checkAnswers(event:MouseEvent):void
{
    switch(firstCB)
    {
        case "True":
        {
            firstQ_txt.textColor=0x00FF00; 
            break;
        }
        case "False":
        {
            firstQ_txt.textColor=0xFF0000; 
            break; 
        }
    }

    switch(secondCB)
    {
        case "True":
        {
            secondQ_txt.textColor=0x00FF00; 
            break; 
        }
        case "False":
        {
            secondQ_txt.textColor=0xFF0000; 
            break; 
        }
    }

    switch(thirdCB)
    {
        case "True":
        {
            thirdQ_txt.textColor=0x00FF00; 
            break; 
        }
        case "False":
        {
            thirdQ_txt.textColor=0x00FF00; 
            break; 
        }
    }

    switch(fourthCB)
    {
        case "True":
        {
            fourthQ_txt.textColor=0x00FF00; 
            break; 
        }
        case "False":
        {
            fourthQ_txt.textColor=0xFF0000; 
            break; 
        }
    }

    switch(fifthCB)
    {
        case "True":
        {
            fifthQ_txt.textColor=0x00FF00; 
            break; 
        }
        case "False":
        {
            fifthQ_txt.textColor=0xFF0000; 
            break; 
        }
    }

}

1 个答案:

答案 0 :(得分:0)

selectedLabel的{​​{1}}属性提供了当前所选组合框的字符串。

ComboBox