1
我是新來的as3,請你幫我。1084:語法錯誤:期待rightbrace功能之前
得到此錯誤1084:語法錯誤:期待rightbrace函數之前。
請讓我知道你是否想要其他的代碼。這一行可能無法解釋所有需要的信息。
public function U1A4_Monnaie():void
{
編輯
這裏是原來的代碼。我算括號都關閉和開啓的數量,他們似乎與海誓山盟投其所好,但我可能是錯的...
package {
import flash.display.MovieClip;
import flash.display.Sprite;
import flash.events.MouseEvent;
import flash.text.TextField;
import flash.text.TextFieldAutoSize;
import flash.text.TextFieldType;
import flash.text.TextFormat;
import flash.text.TextInteractionMode;
public class U1A4_Monnaie extends MovieClip {
private var monMessage:TextField=new TextField;
private var maMiseEnForme:TextFormat=new TextFormat;
**private var btnSoumettre:Sprite;
private var montant:TextField=new TextField;**
public function U1A4_Monnaie():void
{
montant = new TextField();
montant.border=true;
montant.text = "100";
montant.height = 20;
montant.type = TextFieldType.INPUT;
this.addChild(montant);
btnSoumettre = new Sprite();
btnSoumettre.y = 22;
btnSoumettre.graphics.beginFill(0xFF0000, 1);
btnSoumettre.graphics.drawRect(0, 0, 100, 20);
btnSoumettre.graphics.endFill();
this.addChild(btnSoumettre);
btnSoumettre.addEventListener(MouseEvent.CLICK, calculeMonnaie);
}
private function calculeMonnaie(event:MouseEvent):void {
nouvMessage.font="Arial";
nouvMessage.size=20;
nouvMessage.bold=true;
nouvMessage.color=0xFFFFFF;
nouvMessage.x=20;
nouvMessage.y=20;
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 + "$" +
"\n25 cents: " + pieces25Cents +
"\n10 cents: " + pieces10Cents +
"\n5 cents: " + pieces5Cents +
"\n1 cent: " + pieces1Cent);
trace()monMessage.text=nouvMessage;
addChild(monMessage);
}
}
可能刪除':void' –
沒有工作。我試圖找出它,但仍然沒有運氣。感謝您的幫助! – Larocque
您提供的腳本沒有問題。錯誤可能在這些行之前。 – Organis