无法在TextField中输入数字

时间:2015-12-14 12:04:57

标签: actionscript-3 flash

我试图创建一个计算器来计算功率能量及其成本。 以下是我的代码,虽然它没有错误,但我无法输入数字。我不能输入字母表,因为我限制它但我也不能输入数字。

import flash.events.MouseEvent;

ok_btn.addEventListener(MouseEvent.CLICK, multiplyClick);
back_btn.addEventListener(MouseEvent.CLICK, backClick);

var multiSym:Boolean  =  false; 
var backSym:Boolean  =  false;

usage.restrict = "0-9";
power.restrict = "0-9";
power.border = true;
usage.border = true;

var input1:String;
var input2:String;
var multiResult:Number;

function multiplyClick(event:MouseEvent):void
{
    multiSym = true;
    backSym = false;

    input1 = usage.text;
    input2 = power.text;

    if(multiSym == true){
        multiResult = parseInt(input1)* parseInt(input2);
        multiResult.toString();
        total_power.text  =  String(multiResult);
    } else {
        total_power.text = "Please Choose an option";
    }   
}

function backClick(event:MouseEvent):void
{
    multiSym = false;
    backSym = true;
}

stop();
有人能帮帮我吗? 谢谢

0 个答案:

没有答案