adobe flash AS6上的乘法游戏问题

时间:2016-05-04 18:11:58

标签: flash if-statement math timer actionscript

我是Adobe Flash的新手,我正在创建我的数学游戏问题,首先计时器不起作用,因为它在我运行程序时甚至没有显示,其次是我的if语句不起作用,我正在尝试这样做,因为当我正确回答问题时,我获得了10分并且它产生了一个随机问题,现在点数系统只有当值的总和= 0时才会上升,而不管我是什么输入

package  {
    import flash.display.MovieClip;
    import flash.events.*;
    import flash.events.TimerEvent;
    import flash.utils.Timer;

    public class Main extends MovieClip {
        var Num1:int ;
        var Num2:int ;
        var Answer:int ;
        var Score:int=0;
        var UserInput:String;
        var myTimer:Timer = new Timer(1000,60);

        public function Main() {
            // constructor code
            gotoAndStop(1);
            Start.addEventListener(MouseEvent.CLICK, StartFunct);
        }

        function StartFunct(e:Event) {
            gotoAndStop(2);
            button.addEventListener(MouseEvent.CLICK,clickhandler);

            button.addEventListener(MouseEvent.CLICK,clickhandler2);
            button.addEventListener(MouseEvent.CLICK,checkFunction);
            myTimer.addEventListener(TimerEvent.TIMER,Endgame);
        }

        function checkFunction(event:MouseEvent):void {
            Answer= Num1*Num2;
            if(int(TotalBox) == Answer) {
                Score=Score+10
            }
            else Score=Score
        }

        function clickhandler(event:MouseEvent):void {
            Num1  = Math.floor(Math.random()*10);
            Num2  = Math.floor(Math.random()*10);

            num1Box.text = String(Num1);
            num2Box.text = String(Num2);
            UserInput = "";
        }

        function clickhandler2(event:MouseEvent):void {
            Score = Score;
            ScoreBox.text = String(Score);
        }

        function Endgame(event:TimerEvent):void {
            if (myTimer.currentCount==0) 
                gotoAndPlay(3)
        }
    }
}

0 个答案:

没有答案