I'm new to as3 can you help me please.
getting this error 1084: Syntax error: expecting rightbrace before function.
Please let me know if you would like the rest of the code. This one line might not explain all of the needed information.
public function U1A4_Monnaie():void
{
EDIT
Here is the original code. I counted the amount of brackets both closing and opening, and they seem to match up with eachother, but I might be wrong...
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);
}
}
That error can sometimes be deceiving because it can be thrown even if the all the brackets are there.
In your case, the issue is this line (second to last line of code):
trace()monMessage.text=nouvMessage;
There should be a terminator after trace()
to separate it from the next character.
trace(); monMessage.text=nouvMessage;
Or (since an empty trace is rather pointless) perhaps you mean to do the following:
trace(monMessage.text = nouvMessage);
which would trace the updated value of monMessage.text
.
Though most would probably agree that this is cleaner:
monMessage.text = mouvMessage;
trace(monMessage.text);