• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
Exit
0

1084:Syntax error:expecting rightparen before "true"

New Here ,
Mar 29, 2020 Mar 29, 2020

Copy link to clipboard

Copied

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.

TOPICS
ActionScript , Code , Error

Views

340

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Mar 29, 2020 Mar 29, 2020

Copy link to clipboard

Copied

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".

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Jun 10, 2020 Jun 10, 2020

Copy link to clipboard

Copied

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. ^-^

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Jun 11, 2020 Jun 11, 2020

Copy link to clipboard

Copied

LATEST

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

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines