dimanche 27 septembre 2015

Verification button not working AS3

I'm new to programming and I've made a math question generator in as3 But it doesn't seem to be working the timer isn't the problem, the problem is (see line 34 and below) that it doesn't trace "correcto" when I click on the "verificar" button when the imput text has the right answer. please help, and please, again, consider that i'm new to programming. Any help is accepted, thank you. :)

import flash.utils.Timer;
import flash.events.MouseEvent;
import flash.events.TimerEvent;
stop()
var reloj:Timer = new Timer(1000,60);
startButton.addEventListener(MouseEvent.CLICK, startTimer);
reloj.addEventListener(TimerEvent.TIMER, moveHand);
reloj.addEventListener(TimerEvent.TIMER_COMPLETE, endTimer);
function startTimer(e:MouseEvent):void
{
        reloj.start();
        startButton.visible = false;
}
function moveHand(e:TimerEvent):void
{
        segundero.rotation = segundero.rotation + 6
}
function endTimer(e:TimerEvent):void
{
        trace("Se agotó el tiempo");
        gotoAndPlay (1, "1");
}
nuevo.addEventListener(MouseEvent.CLICK, generarPregunta);
function generarPregunta(MouseEvent):void
{
        var random1:Number = Math.floor(Math.random()*25)
        var random2:Number = Math.floor(Math.random()*25)
        var array:Array = new Array ("+","-","*","/")
        var randomIndex:int = Math.floor (Math.random()*4)
        SimbMat.text = array [ randomIndex ]
        numI.text = random1 + ""
        numD.text = random2 + ""
}
verificar.addEventListener(MouseEvent.CLICK, verificarRespuesta);
function verificarRespuesta(MouseEvent):void
{
        if (String(SimbMat) == "+")
        {
                if (Number(numI.text) + Number(numD.text) == Number(imput.text))
                {trace("correcto")}
                else
                {trace("incorrecto")}
        }
        else if (String(SimbMat) == "-")
        {
                if (Number(numI.text) - Number(numD.text) == Number(imput.text))
                {trace("correcto")}
                else
                {trace("incorrecto")}
        }
        else if (String(SimbMat) == "*")
        {
                if (Number(numI.text) * Number(numD.text) == Number(imput.text))
                {trace("correcto")}
                else
                {trace("incorrecto")}
        }
        else if (String(SimbMat) == "/")
        {
                if (Number(numI.text) / Number(numD.text) == Number(imput.text))
                {trace("correcto")}
                else
                {trace("incorrecto")}
        }
}

Aucun commentaire:

Enregistrer un commentaire