我目前正在對點鈔機一個個人項目,我真的堅持我的代碼。如果有人能幫助我,那麼最終的答案文本框就不會出現在我的項目中。ActionScript代碼錯誤
該項目是一個貨幣計算器,包括1美分,5美分,10美分,25美分,1美元& 2美元。
我的代碼:
package {
import flash.display.*;
import flash.text.*;
import flash.events.MouseEvent;
public class U1A4_Monnaie extends MovieClip {
private var monMessage:TextField=new TextField;
private var maMiseEnForme:TextFormat=new TextFormat;
public function U1A4_Monnaie():void
{
btnSoumettre.addEventListener(MouseEvent.CLICK, calculeMonnaie);
}
private function calculeMonnaie(event:MouseEvent):void {
maMiseEnForme.font="Arial";
maMiseEnForme.size=20;
maMiseEnForme.bold=true;
maMiseEnForme.color=0x660000;
monMessage.x=20;
monMessage.y=190;
monMessage.autoSize=TextFieldAutoSize.LEFT;
monMessage.border=true;
monMessage.defaultTextFormat=maMiseEnForme;
var somme:Number;
var totalCents:int;
var pieces25Cents:int=0;
var pieces10Cents:int=0;
var pieces5Cents:int=0;
var pieces1Cent:int=0;
var restant:int=0;
var nouvMessage:String;
somme = Number(montant.text);
totalCents = int(somme * 100);
pieces25Cents = totalCents/25;
restant= totalCents % 25;
pieces10Cents = restant/10;
restant = restant % 10;
pieces5Cents = restant/5;
restant = restant % 5;
pieces1Cent = restant;
montant.text=" ";
nouvMessage =("Montant à transformer en monnaie: " + somme + "$" +
"\n\n25 cents: " + pieces25Cents +
"\n10 cents: " + pieces10Cents +
"\n5 cents: " + pieces5Cents +
"\n1 cent: " + pieces1Cent);
monMessage.text=nouvMessage;
addChild(monMessage);
}
}
}
使用** **調試選項,而不要**測試影片**看到錯誤。任何錯誤消息?爲什麼'nouvMessage ='內容放在括號內? –