Skip to main content
cynthiaw57590876
Participant
January 18, 2017
Answered

1013: The private attribute may be used only on class property definitions.

  • January 18, 2017
  • 2 replies
  • 328 views

I am a beginner with Action 3 scripting. I wrote one and am getting the above errors. I'm using Animate cc 2017. I think I know where they are, just not how to fix them. Below is the script. Thank you for looking.

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);

            falseBtn.addEventListener(MouseEvent.CLICK, falsePressed);

}

        }

    private function dataReady(e:Event):void {

        questionArray = questionBank.buildBank();

        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+"/100 points";

  questionText.text = "Game Over!";

}

    private function truePressed(e:MouseEvent):void {

    if(statusMsg.text == ""){

    if(currentAnswer == "true"){

      currentScore += 100/questionMax;

      statusMsg.text = "CORRECT!";

    }else{

      statusMsg.text = "WRONG";

    }

    setTimeout(newQuestion, 1000);

  }

}

        private function falsePressed(e:MouseEvent):void {

  if(statusMsg.text == ""){

    if(currentAnswer == "false"){

      currentScore += 100/questionMax;

      statusMsg.text = "CORRECT!";

    }else{

      statusMsg.text = "WRONG";

    }

    setTimeout(newQuestion, 1000);

  }

}

        private function newQuestion():void {

        statusMsg.text = "";

        grabQuestion();

}

    }

  

}

errors are:

C:\Users\cynth\Desktop\Excersizes\com\josephlabrecque\QuizGame.as, Line 39, Column 3    1013: The private attribute may be used only on class property definitions.

C:\Users\cynth\Desktop\Excersizes\com\josephlabrecque\QuizGame.as, Line 43, Column 1    1013: The private attribute may be used only on class property definitions.

C:\Users\cynth\Desktop\Excersizes\com\josephlabrecque\QuizGame.as, Line 56, Column 2    1013: The private attribute may be used only on class property definitions.

C:\Users\cynth\Desktop\Excersizes\com\josephlabrecque\QuizGame.as, Line 60, Column 2    1013: The private attribute may be used only on class property definitions.

C:\Users\cynth\Desktop\Excersizes\com\josephlabrecque\QuizGame.as, Line 71, Column 3    1013: The private attribute may be used only on class property definitions.

C:\Users\cynth\Desktop\Excersizes\com\josephlabrecque\QuizGame.as, Line 82, Column 3    1013: The private attribute may be used only on class property definitions.

This topic has been closed for replies.
Correct answer Ned Murphy

The problem might be the second curly bracket you have after your public QuizGame function.  Unless my eyes are deceiving me it is closing the class definition prematurely.

2 replies

cynthiaw57590876
Participant
January 18, 2017

that seemed to open the function but did not solve the attribute errors

Ned Murphy
Ned MurphyCorrect answer
Legend
January 18, 2017

The problem might be the second curly bracket you have after your public QuizGame function.  Unless my eyes are deceiving me it is closing the class definition prematurely.