Highlighted

1084:Syntax error:expecting rightparen before "true"

New Here ,
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

240

Likes

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

1084:Syntax error:expecting rightparen before "true"

New Here ,
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

241

Likes

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
Mar 29, 2020 0
Adobe Community Professional ,
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".

Likes

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
Reply
Loading...
Mar 29, 2020 1
New Here ,
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. ^-^

Likes

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
Reply
Loading...
Jun 10, 2020 0
ClayUUID LATEST
Adobe Community Professional ,
Jun 11, 2020

Copy link to clipboard

Copied

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

Likes

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
Reply
Loading...
Jun 11, 2020 0