0

我正在使用 actionscript 和 flash 创建一个移动应用程序(我知道它已经过时了)。当用户选择答案时,该应用程序是一个测验,它正在返回下一个问题我遇到的问题是,当它返回结果时,它会在 Question1、Question2、Question4、Question8 中返回结果。我希望它增加 1 我已经尝试过 VARIABLE++、++VARIABLE 和 VARIABLE = VARIABLE + 1。方法有什么想法为什么它不增加 1?

import flash.events.Event;

stop();

var TEST:String = "";
txt_ans.text = "";
var SCORE:int = 0;
var Qnumber:Number = 1;

stage.addEventListener(Event.ENTER_FRAME, onFrameEnter);

function onFrameEnter(e:Event):void
{

LoadQuestionVars.call();
}
function LoadQuestionVars():void
{
if (Qnumber > 10)
{

    gotoAndStop(10);
}
else
{

    var formVars:URLVariables = new URLVariables();
    var variableRequest:URLRequest = new URLRequest("requestp");
    variableRequest.method = URLRequestMethod.POST;
    variableRequest.data = formVars;
    var varLoader:URLLoader = new URLLoader();
    varLoader.dataFormat = URLLoaderDataFormat.VARIABLES;


    formVars.question1 = Qnumber;


    varLoader.addEventListener(Event.COMPLETE, showTest);



    varLoader.load(variableRequest);

    function showTest(e:Event):void
    {

        result_text.text = e.target.data.systemResult;
        TESTNAME = result_text.text;


        var formVars:URLVariables = new URLVariables();
        var variableRequest:URLRequest = new URLRequest("hrequest");
        variableRequest.method = URLRequestMethod.POST;
        variableRequest.data = formVars;
        var varLoader:URLLoader = new URLLoader();
        varLoader.dataFormat = URLLoaderDataFormat.VARIABLES;


        formVars.question1 = Qnumber;


        varLoader.addEventListener(Event.COMPLETE, showQuestion);



        varLoader.load(variableRequest);

        function showQuestion(e:Event):void
        {
            question_text.text = e.target.data.question;

            var formVars:URLVariables = new URLVariables();
            var variableRequest:URLRequest = new URLRequest("hrequest");
            variableRequest.method = URLRequestMethod.POST;
            variableRequest.data = formVars;
            var varLoader:URLLoader = new URLLoader();
            varLoader.dataFormat = URLLoaderDataFormat.VARIABLES;


            formVars.question1 = Qnumber;


            varLoader.addEventListener(Event.COMPLETE, showanswere1);



            varLoader.load(variableRequest);

            function showanswere1(e:Event):void
            {
                Answere1.text = e.target.data.answere1;



                var formVars:URLVariables = new URLVariables();
                var variableRequest:URLRequest = new URLRequest("hrequest");
                variableRequest.method = URLRequestMethod.POST;
                variableRequest.data = formVars;
                var varLoader:URLLoader = new URLLoader();
                varLoader.dataFormat = URLLoaderDataFormat.VARIABLES;


                formVars.question1 = Qnumber;


                varLoader.addEventListener(Event.COMPLETE, showanswere2);



                varLoader.load(variableRequest);

                function showanswere2(e:Event):void
                {
                    Answere2.text = e.target.data.answere2;

                    var formVars:URLVariables = new URLVariables();
                    var variableRequest:URLRequest = new URLRequest("requestp");
                    variableRequest.method = URLRequestMethod.POST;
                    variableRequest.data = formVars;
                    var varLoader:URLLoader = new URLLoader();
                    varLoader.dataFormat = URLLoaderDataFormat.VARIABLES;


                    formVars.question1 = Qnumber;


                    varLoader.addEventListener(Event.COMPLETE, showanswere3);



                    varLoader.load(variableRequest);

                    function showanswere3(e:Event):void
                    {
                        Answere3.text = e.target.data.answere3;

                        var formVars:URLVariables = new URLVariables();
                        var variableRequest:URLRequest = new URLRequest("requestp");
                        variableRequest.method = URLRequestMethod.POST;
                        variableRequest.data = formVars;
                        var varLoader:URLLoader = new URLLoader();
                        varLoader.dataFormat = URLLoaderDataFormat.VARIABLES;


                        formVars.question1 = Qnumber;


                        varLoader.addEventListener(Event.COMPLETE, showanswere4);



                        varLoader.load(variableRequest);

                        function showanswere4(e:Event):void
                        {
                            Answere4.text = e.target.data.answere4;

                            var formVars:URLVariables = new URLVariables();
                            var variableRequest:URLRequest = new URLRequest("request");
                            variableRequest.method = URLRequestMethod.POST;
                            variableRequest.data = formVars;
                            var varLoader:URLLoader = new URLLoader();
                            varLoader.dataFormat = URLLoaderDataFormat.VARIABLES;


                            formVars.question1 = Qnumber;


                            varLoader.addEventListener(Event.COMPLETE, ANSWERE);



                            varLoader.load(variableRequest);

                            function ANSWERE(e:Event):void
                            {
                                txt_ans.text = e.target.data.answereshow;



                            }
                        }

                    }
                }
            }
        }

    }
    stage.removeEventListener(Event.ENTER_FRAME,onFrameEnter);




    Multitouch.inputMode = MultitouchInputMode.TOUCH_POINT;
    BTN_ANS1.addEventListener(TouchEvent.TOUCH_TAP, Answere1ACC);

    function Answere1ACC(e:TouchEvent):void
    {
        if (txt_ans.text == "ANS1")
        {
            SCORE = SCORE + 1;
        }
        ClearTextFields.call();

    }
    Multitouch.inputMode = MultitouchInputMode.TOUCH_POINT;
    BTN_ANS2.addEventListener(TouchEvent.TOUCH_TAP, Answere2ACC);

    function Answere2ACC(e:TouchEvent):void
    {
        if (txt_ans.text == "ANS2")
        {
            SCORE = SCORE + 1;
        }
        ClearTextFields.call();

    }
    Multitouch.inputMode = MultitouchInputMode.TOUCH_POINT;
    BTN_ANS3.addEventListener(TouchEvent.TOUCH_TAP, Answere3ACC);

    function Answere3ACC(e:TouchEvent):void
    {
        if (txt_ans.text == "ANS3")
        {
            SCORE = SCORE + 1;
        }
        ClearTextFields.call();


    }
    Multitouch.inputMode = MultitouchInputMode.TOUCH_POINT;
    BTN_ANS4.addEventListener(TouchEvent.TOUCH_TAP, Answere4ACC);

    function Answere4ACC(e:TouchEvent):void
    {
        if (txt_ans.text == "ANS4")
        {
            SCORE = SCORE + 1;
        }
        ClearTextFields.call();
    }
    function ClearTextFields():void
    {
        result_text.text = "";
        question_text.text = "";
        Answere1.text = "";
        Answere2.text = "";
        Answere3.text = "";
        Answere4.text = "";
        txt_ans.text = "";
        LoadQuestionVars.call();

    }


}
Qnumber++;
}
4

1 回答 1

0

我做了一个跟踪,问题是我是从第一个函数中调用的,所以每次运行它都会运行两次,我在增量之前关闭了函数,它工作得很好。

于 2013-04-12T09:06:37.923 回答