我正在尝试在 FLASH AS 3.0 中构建一个应用程序来快速计算发票。我已经完成了大部分工作,但现在我不能让它只显示两位小数而不是带有大小数的金额。
到目前为止,这是我的代码:
import fl.managers.StyleManager;
this.stop();
var Format1:TextFormat = new TextFormat();
Format1.size = 17;
Format1.font = "Arial Rounded MT Bold";
Format1.align = "right";
StyleManager.setComponentStyle(TextInput, "textFormat", Format1);
borrar.addEventListener(MouseEvent.CLICK, escuchadorLimpiar);
function escuchadorLimpiar(event) {
a1.text="";
a2.text="";
a3.text="";
a4.text="";
b1.text="";
b2.text="";
b3.text="";
b4.text="";
c1.text="";
c2.text="";
c3.text="";
c4.text="";
subtotal.text="";
iva.text="";
total.text="";
}
a1.restrict="0-9";
a2.restrict="0-9";
a3.restrict="0-9";
a4.restrict="0-9";
b1.restrict="0-9";
b2.restrict="0-9";
b3.restrict="0-9";
b4.restrict="0-9";
c1.restrict="0-9";
c2.restrict="0-9";
c3.restrict="0-9";
c4.restrict="0-9";
subtotal.restrict="0-9";
iva.restrict="0-9";
total.restrict="0-9";
calcular.addEventListener(MouseEvent.CLICK, onSumar1, false, 0, true);
function onSumar1(evt:MouseEvent):void
{
c1.text = String(Number(a1.text) * Number(b1.text) / Number(escalar.text));
c2.text = String(Number(a2.text) * Number(b2.text) / Number(escalar.text));
c3.text = String(Number(a3.text) * Number(b3.text) / Number(escalar.text));
c4.text = String(Number(a4.text) * Number(b4.text) / Number(escalar.text));
subtotal.text = String(Number(c1.text) + Number(c2.text) + Number(c3.text) + Number(c4.text));
iva.text = String(Number(total.text) - (Number(subtotal.text)));
total.text = String(Number(subtotal.text) * Number(escalar.text));
}
我有一个不可见的输入文本,其中包含一个名为 escalar 的常数 (1.12)。
有什么帮助吗?