1

適切な文字列を拡張するのに助けが必要ですか?? 数値ステッパーおよび/またはテキスト表示フィールドを通貨形式にフォーマットします。FLA は、 CS5 フラッシュ FLAからダウンロードできます。ありがとう

 /* start application */
import flash.geom.Matrix;
import flash.display.Bitmap;
import flash.display.BitmapData;
import flash.text.TextField;
import flash.net.URLLoader;
import flash.globalization.CurrencyFormatter;


//comboBox, I populate values displayed to users

    this.comptype.addItem ( { label: "clerical" } );
    this.comptype.addItem ( { label: "concrete" } );
    this.comptype.addItem ( { label: "demolition" } );
    this.comptype.addItem ( { label: "electricians" } );
    this.comptype.addItem ( { label: "excavation" } );
    this.comptype.addItem ( { label: "HVAC/Plumbing" } );
    this.comptype.addItem ( { label: "oil and gas" } );
    this.comptype.addItem ( { label: "road/bridge construction" } );
    this.comptype.addItem ( { label: "roofing" } );
    this.comptype.addItem ( { label: "sewer construction" } );
    this.comptype.addItem ( { label: "truck driving" } );
    this.comptype.addItem ( { label: "warehousing" } );

this.comptype.addEventListener (Event.CHANGE, selectOrder); 
function selectOrder (event:Event) : void

    {
        if (this.comptype.selectedItem.label == "clerical") this.orderTotal.text = ("3.00");
        if (this.comptype.selectedItem.label == "concrete") this.orderTotal.text = ("8.00"); //make sure my values match the above values EXACTLY
        if (this.comptype.selectedItem.label == "demolition") this.orderTotal.text = ("10.00"); //make sure my values match the above values EXACTLY
        if (this.comptype.selectedItem.label == "electricians") this.orderTotal.text = ("5.00"); //make sure my values match the above values EXACTLY
        if (this.comptype.selectedItem.label == "excavation") this.orderTotal.text = ("8.00"); //make sure my values match the above values EXACTLY
        if (this.comptype.selectedItem.label == "HVAC/Plumbing") this.orderTotal.text = ("6.00"); //make sure my values match the above values EXACTLY
        if (this.comptype.selectedItem.label == "oil and gas") this.orderTotal.text = ("13.00"); //make sure my values match the above values EXACTLY
        if (this.comptype.selectedItem.label == "road/bridge construction") this.orderTotal.text = ("10.00"); //make sure my values match the above values EXACTLY
        if (this.comptype.selectedItem.label == "roofing") this.orderTotal.text = ("18.00"); //make sure my values match the above values EXACTLY
        if (this.comptype.selectedItem.label == "sewer construction") this.orderTotal.text = ("9.00"); //make sure my values match the above values EXACTLY
        if (this.comptype.selectedItem.label == "truck driving") this.orderTotal.text = ("13.00"); //make sure my values match the above values EXACTLY
        if (this.comptype.selectedItem.label == "warehousing") this.orderTotal.text = ("7.00"); //make sure my values match the above values EXACTLY

    }
this.outline.calcBtn.addEventListener (MouseEvent.CLICK, goCalc);
function goCalc (Event:MouseEvent) : void

            {
        this.outline.annualSavings.text = (this.staffrate.value-(14.15 + parseInt(this.orderTotal.text)))*this.payroll.value;
        //this.outline.docCostMonth.text = (this.timesPerDay.value * 260) / 12 * this.docProcCost.value;
        //this.outline.docCostYear.text = (this.outline.docCostMonth.text *12);
        //this.outline.annualSavings.text = ((this.procAutoSaving.value * this.outline.docCostYear.text) / 100);
        }


var cf:CurrencyFormatter = new CurrencyFormatter( "en_US" );
this.payroll.value = this.payrollOut;
cf.format( this.payrollOut.text );  //??
4

3 に答える 3

0

問題は、変数の型に注意を払っていないことです。

this.payrollOut -- テキストフィールドです

this.payrollOut.text -- そのテキストフィールドに含まれるテキストです

this.payroll.value にテキストフィールドまたはテキスト値を割り当てることはできません

したがって、期待される型 (この場合は数値) に変換する必要があります。

this.payroll.value = Number(this.payrollOut.text);

cf.format も Number 値を想定しており、String を返します。

使用例は次のとおりです。

var payrollAmount:Number = 400;
var payrollCurrencyAmount:String = cf.format(payrollAmount);

私が見たコードには他にも問題があります - payrollOut には値がありません - そのため、まだ期待どおりに機能しませんが、これで差し迫った問題は解決します。

于 2011-04-24T18:10:31.683 に答える