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

TypeError: Error 1009 in Adobe Animate CC AS3

New Here ,
Nov 15, 2016 Nov 15, 2016

Copy link to clipboard

Copied

Hello again! I'm creating an assessment quiz for my game. It works fine (just the partial app) but, when I proceed to the next frame which is the assessment quiz, it didn't work. Suddenly, the run-time error appears:

TypeError: Error #1009: Cannot access a property or method of a null object reference.
  at
PropoCon/frame11()[PropoCon::frame11:35]
  at flash
.display::MovieClip/gotoAndStop()
  at
PropoCon/sunod9()[PropoCon::frame10:6]

Here's my code from frame 11:

import flash.text.TextField;

var qno = 0;
var rnd1;
var rnd2;
tick
.visible = false;
cross
.visible = false;
korekokWin
.visible = false;
var right_answers = 0;
var wrong_answers = 0;

addChild
(korekokWin);

function change_question() {
  korekokWin
.visible = false;
  
if (tick.visible) {
  right_answers
++;
  
}
  
if (cross.visible) {
  wrong_answers
++;
  
}
  
if (qno == questions.length) {
  gotoAndPlay
(11);
  
}
  
else {
  tick
.visible = false;
  cross
.visible = false;
  rnd1
= Math.ceil(Math.random() * 3);
  rnd2
= Math.ceil(Math.random() * questions.length) - 1;
  tanong
.text = questions[rnd2];
  
if (questions[rnd2] == "x") {
  change_question
();
  
}
  questions
[rnd2] = "x";
  enable_disable
(1);//this is the line 35
  
if (rnd1 == 1) {
  opt1
.text = answers[rnd2][0];
  opt2
.text = answers[rnd2][1];
  opt3
.text = answers[rnd2][2];
  
}
  
if (rnd1 == 2) {
  opt1
.text = answers[rnd2][2];
  opt2
.text = answers[rnd2][0];
  opt3
.text = answers[rnd2][1];
  
}
  
if (rnd1 == 3) {
  opt1
.text = answers[rnd2][1];
  opt2
.text = answers[rnd2][2];
  opt3
.text = answers[rnd2][0];
  
}
  
}
}

function enable_disable(a) {
  
if (a == 0) {
  shade1
.mouseEnabled = false;
  shade2
.mouseEnabled = false;
  shade3
.mouseEnabled = false;
  
}
  
if (a == 1) {
  shade1
.mouseEnabled = true;
  shade2
.mouseEnabled = true;
  shade3
.mouseEnabled = true;
  
}
}

change_question
();

btnNek
.addEventListener(MouseEvent.CLICK, ButtonAction1);
function ButtonAction1(eventObject: MouseEvent😞void {
  qno
++;
  change_question
();
}

shade1
.addEventListener(MouseEvent.CLICK, ButtonAction2);
shade2
.addEventListener(MouseEvent.CLICK, ButtonAction3);
shade3
.addEventListener(MouseEvent.CLICK, ButtonAction4);

function ButtonAction2(eventObject: MouseEvent😞void {
  enable_disable
(0);
  
if (rnd1 == 1) {
  tick
.visible = true;
  tick
.y = shade1.y;
  korekokWin
.visible = false;
  
}
  
else {
  cross
.visible = true;
  cross
.y = shade1.y;
  korekokWin
.visible = true;
  korekokWin
.koreksyon.text = korek[rnd2];
  
}
}
function ButtonAction3(eventObject: MouseEvent😞void {
  enable_disable
(0);
  
if (rnd1 == 2) {
  tick
.visible = true;
  tick
.y = shade2.y;
  korekokWin
.visible = false;
  
}
  
else {
  cross
.visible = true;
  cross
.y = shade2.y;
  korekokWin
.visible = true;
  korekokWin
.koreksyon.text = korek[rnd2];
  
}
}
function ButtonAction4(eventObject: MouseEvent😞void {
  enable_disable
(0);
  
if (rnd1 == 3) {
  tick
.visible = true;
  tick
.y = shade3.y;
  korekokWin
.visible = false;
  
}
  
else {
  cross
.visible = true;
  cross
.y = shade3.y;
  korekokWin
.visible = true;
  korekokWin
.koreksyon.text = korek[rnd2];
  
}
}

And this is from frame 10:

stop();
next.addEventListener(MouseEvent.CLICK, sunod9);
backward
.addEventListener(MouseEvent.CLICK, balik8);

function sunod9(event:MouseEvent😞void{
  gotoAndStop
(11);//this is in the line 6
}

function balik8(event:MouseEvent😞void{
  gotoAndStop
(9);
}

Both codes are from movieclip timeline. My codes seem right but I dunno what would be the cause of problem. Is there something wrong in my code? Did you think that my code is something incomplete or what? What do you think is the main cause of those problems? Any suggestions or help will be appreciated. Thanks!

Views

784

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
Community Expert ,
Nov 16, 2016 Nov 16, 2016

Copy link to clipboard

Copied

LATEST

comment out that enable_disable function call at line 11.  if the error resolves, one or more of those shade objects don't exist.  use the trace function to debug.

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