Skip to main content
Participant
March 29, 2020
Question

1084:Syntax error:expecting rightparen before "true"

  • March 29, 2020
  • 1 reply
  • 480 views

Hi, Im fairly new to actionscript and im actually following a pdf my lecturer sent me. After checking my codes repeatedly i cant seem to find where the errors come from. Here is my codes

 

package com.josephlabrecque {

import flash.display.MovieClip;
import flash.text.TextField;
import flash.display.SimpleButton;
import flash.events.Event;
import com.josephlabrecque.QuestionBank;
import flash.events.MouseEvent;
import flash.utils.setTimeout;


public class QuizGame extends MovieClip {

public var trueBtn: SimpleButton;
public var falseBtn: SimpleButton;
public var questionText:TextField;
public var statusMsg:TextField;

private var questionBank:QuestionBank;
private var questionArray:Array;
private const questionMax:int = 5;
private var questionCount:int = 0;
private var currentAnswer:String;
private var currentScore:int = 0;

public function QuizGame() {
statusMsg.text = "";
questionArray = new Array();
questionBank = new QuestionBank();
questionBank.addEventListener(Event.COMPLETE,dataReady);
trueBtn.addEventListener(MouseEvent.CLICK, truePressed);
falsBtn.addEventListener(MouseEvent.CLICK, falsePressed);
}

private function truePressed(e:MouseEvent):void {
if(statusMsg.text == ""){
if(currentAnswer -- "true"){
curruntScore += 100/questionMax;
statusMsg.text = "CORRECT"
}else{
statusMsg.text = "WRONG";
}
setTimeout(newQuestion, 1000);
}
}

private function falsePressed(e:MouseEvent):void {
if(statusMsg.text == ""){
if(currentAnswer -- "false"){
curruntScore += 100/questionMax;
statusMsg.text = "CORRECT"
}else{
statusMsg.text = "WRONG";
}
setTimeout(newQuestion, 1000);
}
}

private function dataReady(e:Event):void {
questionArray = questionBank.buildBank();
grabQuestion();
}

private function newQuestion ():void {
statusMsg.text = "";
trace(currentScore);
grabQuestion();
}

private function grabQuestion():void {
if(questionCount < questionMax){
var max:int = questionArray.length-1;
var rq:int = Math.floor(Math.random() * (max - 0 + 1));
var ta:Array = questionArray.splice(rq, 1);
questionText.text = ta[0].q;
currentAnswer = ta[0].tf;
questionCount++;
} else{
gameOver();
}
}

private function gameOver():void{
statusMsg.text = currentScore+"/100points";
questionText.text = "Game Over";
}
}
}

 

The red text is where im having the same syntax error (as mentioned in the subject field), ive been trying to rectify this for more than 2hr and still cant seem to find the soluction. Any help would be much appreciated. Thanks in advance.

This topic has been closed for replies.

1 reply

Legend
March 29, 2020

The correct syntax to use is literally right above each line you're having trouble with. You typed minus minus instead of equals equals.

 

And I'm pretty sure "current" isn't spelled "currunt".

PandudeAuthor
Participant
June 11, 2020

Hi, thank you for helping me. I had a problem and couldnt reply back.

So i tried correcting it, but im still having the same problem... and idea why?

Thanl you. ^-^

Legend
June 11, 2020

If you're still having the same problem, then you didn't correct it.