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

What would be the best solution to fix Error 1009 in AS3?

New Here ,
Jul 08, 2017 Jul 08, 2017

Hello! I'll ask once again about error 1009. When I go to the main game, my character walked, the questionnaire appears, and then the "Correct!" window appears, so all of it exists in frame 75. So in the "Correct!" window has "Go" button, when I clicked it I've got received error 1009. It supposed to be when I clicked "Go" button, it supposed to be proceed in frame 76. So here's the message:

TypeError: Error #1009: Cannot access a property or method of a null object reference.

at RECOVER_RECOVER_RECOVER_RECOVER_diemgeym_fla::MainTimeline/frame76()[RECOVER_RECOVER_RECOVER_RECOVER_diemgeym_fla.MainTimeline::frame76:21]

at flash.display::Sprite/constructChildren()

at flash.display::Sprite()

at flash.display::MovieClip()

at QuizQuest2()

at flash.display::MovieClip/gotoAndStop()

at RECOVER_RECOVER_RECOVER_RECOVER_diemgeym_fla::MainTimeline/gura()[RECOVER_RECOVER_RECOVER_RECOVER_diemgeym_fla.MainTimeline::frame75:108]

Here are my codes (actually I separated these but all of these are exist in frame 76 but I combined it altogether):

stop();
import flash.events.Event;
import flash.text.*;
import flash.display.MovieClip;
import flash.net.URLLoader;
import flash.net.URLRequest;
import flash.events.MouseEvent;
import flash.display.DisplayObject;
import flash.geom.Point;
import flash.display.Stage;
//import flash.display.Sprite;
import flash.utils.Timer;
import flash.events.TimerEvent;

var goiX = playergril2.x;
var goiY = playergril2.y;
pausewin2
.visible = false;
corekWin2
.visible = false;
maliWin2
.visible = false;
btnGub
.visible = false;
quizQuest2
.visible = false; // the problematic code

btnForward2
.addEventListener(MouseEvent.CLICK, setpositionz);

function setpositionz(event: MouseEvent) {
goiX
= mouseX;
goiY
= mouseY;
playergril2
.x += 15;
playergril2
.play();
stage
.addEventListener(Event.ENTER_FRAME, loopz);
}

function loopz(event: Event) {
if (keyCollected == false) {
  
if (playergril2.hitTestObject(key2)) {
  key2
.visible = false;
  keyCollected
= true;
  btnGub
.visible = true;
  trace
("key collected");
  
//removeEventListener(Event.ENTER_FRAME, loop);
  
}
}
}
btnGub
.addEventListener(MouseEvent.CLICK, forwardz);
 
function forwardz(event: MouseEvent😞 void {
  quizQuest2
.visible = true;
  playergril2
.visible = false;
}

-------
txtSkor2
.text = String(iskoru2);
txtLives2
.text = String(buhay2);
txtHints2
.text = String(hinto2);
quizQuest2
.nohint2.visible = false;
var sec2: Number = 15;
quizQuest2
.secBox2.text = String(sec2);
var gameTimer2: Timer = new Timer(1000);

gameTimer2
.addEventListener(TimerEvent.TIMER, countDown2);
gameTimer2
.start();


function countDown2(event: TimerEvent😞 void {
sec2
--;
if (sec2 < 0) {
  gameTimer2
.stop();
  gameTimer2
.removeEventListener(TimerEvent.TIMER, countDown2);
  maliWin2
.visible = true;
  quizQuest2
.visible = false;
}
}

quizQuest2
.ans21.addEventListener(MouseEvent.CLICK, buttones2);
quizQuest2
.ans22.addEventListener(MouseEvent.CLICK, buttones2);
quizQuest2
.ans23.addEventListener(MouseEvent.CLICK, buttones2);

function buttones2(event:Event😞void{
 
if(event.currentTarget == quizQuest2.ans23){
  quizQuest2
.visible = false;
  corekWin2
.visible = true;
  iskoru2
+= 10;
}else if(event.currentTarget == quizQuest2.ans21 || event.currentTarget == quizQuest2.ans22){
  quizQuest2
.visible = false;
  maliWin2
.visible = true;
  buhay2
-= 1;
}
}

quizQuest2
.btnHint2.addEventListener(MouseEvent.CLICK, woo);
function woo(event: MouseEvent😞 void {
hinto2
-= 1;
quizQuest2
.txtHint2.visible = true;
if (hinto2 == 0) {
  quizQuest2
.nohint2.visible = true;
}
}
corekWin2
.btnGo2.addEventListener(MouseEvent.CLICK, gura2);

function gura2(event: MouseEvent😞 void {
corekWin2
.visible = false;
quizQuest2
.visible = false;
gotoAndStop
(77);
}

-------
maliWin2
.btnGobak2.addEventListener(MouseEvent.CLICK, bey2);

function bey2(event: MouseEvent😞 void {
maliWin2
.visible = false;
}

------
btnPause2
.addEventListener(MouseEvent.CLICK, oop2);

function oop2(event: MouseEvent😞 void {
stage
.frameRate = 0;
pausewin2
.visible = true;

pausewin2
.btnResume2.addEventListener(MouseEvent.CLICK, op2);
pausewin2
.btnQtm2.addEventListener(MouseEvent.CLICK, oip2);
}
function op2(event: MouseEvent😞 void {
stage
.frameRate = 24;
pausewin2
.visible = false;
}
function oip2(event: MouseEvent😞 void {
gotoAndStop
(1);
}

I double-checked all of my codes, objects (movieclips, textfields and buttons), and instance names that are in the frame 76 and all of them are matched even quizQuest2 is already exists in frame 76 but still, I got the error 1009 and I can't figure out why did happen. I really don't know how I'm going fix it.

So I'll provide some screenshots of my GUI here as follows:

quizquest2.JPG

pausewin2.JPG

loob ng quizquest.JPG

btncorek.JPG

maliwin.JPG

I did provided those screenshots for you to see what's on the frame 76. All of these are existing in the said frame number.

Anyways, what should I do or the best solution on how I fix this problem? I need your help. Thank you.

458
Translate
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 ,
Jul 08, 2017 Jul 08, 2017

give it a new (unique to your app) name and use that in your problematic line of code.

Translate
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 ,
Jul 09, 2017 Jul 09, 2017

You mean I'll rename the instance name instead of quizQuest2, am I right?

Translate
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 ,
Jul 09, 2017 Jul 09, 2017

I did renaming (or giving a unique name) and I put it on the problematic line of code but still, error 1009 appears, the same message as above. Is it object a problem of it? Even the buttons, textfields, and movieclips inside of it have the unique names and the names did match in the instance names and code but still, I get that error. I can't really figure out why did it happen.

Translate
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 ,
Jul 09, 2017 Jul 09, 2017

I mean the name "quizQuest2" changed into another name and then I replaced all the "quizQuest2" into another name in the code

Translate
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 ,
Jul 09, 2017 Jul 09, 2017

this indicates why you're having a problem:  "I mean the name "quizQuest2" changed into another name and then I replaced all the "quizQuest2" into another name in the code".

there's only one instance for each object.  ie, when you first put an object on the timeline in a keyframe, assign it an instance name.  you can add more keyframes after that first one and the object will keep its instance name.  but if you remove/replace the object you must use a different instance name.

Translate
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 ,
Jul 09, 2017 Jul 09, 2017

Uhm.. May I clear something that "quizQuest2" is actually an instance name and I did replace it with another instance name (e.g. Q2) and replace it on what I've written in the code, but not an object name. Sorry for my misinterpretation btw.

Anyways, I did tracing for all of the objects that are present in frame 76, I used those traces with for loop and I put it on the said frame number:

trace(currentFrame);

trace(quizQuest2);

trace(getChildByName("quizQuest2"));

for (var i:int = numChildren - 1; i >= 0; i--){

trace(i, getChildAt(i));

}

And the output (refers above and in-order):

76

null (refers to trace(quizQuest2);)

[object QuizQuest2]

16 [object QuizQuest2]

15 [object PlayerGril]

14 [object CorekWincopy]

13 [object MaliWincopy]

12 [object PauseWincopy]

11 [object TextField]

10 [object TextField]

9 [object TextField]

8 [object Lives]

7 [object Hinteu]

6 [object Scorer]

5 [object SimpleButton]

4 [object SimpleButton]

3 [object SimpleButton]

2 [object Key]

1 [object Door]

0 [object Room2]

So the output for trace(quizQuest2) is null but for trace(getChildByName("quizQuest2"));, the output is [object QuizQuest2]. I don't get it but they seem the same trace. But rest of the objects seem ok.

Translate
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 ,
Jul 09, 2017 Jul 09, 2017

you're not understanding the problem.

Translate
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 ,
Jul 09, 2017 Jul 09, 2017

I can't find a way to make it go wrong. One thing that seems odd is that you have QuizQuest2 as a shared library symbol, usually meaning that you're going to add it to the stage using code. But in your test code presumably you added it to the stage manually?

In the manually dragged version, does that layer have any keyframes between frames 1 and 76? Is the symbol there on stage, as a movieclip, and always with the same name?

Translate
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 ,
Jul 10, 2017 Jul 10, 2017

I have keyframes between frames 1 to 76 but I did combine all features in every frame (e.g. frame 1 has the main menu, frame 2 has instruction module, etc.). All of the objects are present in every frame and I set instance names but I have few symbols/object that its object name and instance name are same. I have a question that suddenly pops out in my mind, is it possible that a movieclip object name and its instance name is the same as what I named in an object may be caused error 1009?

Translate
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 ,
Jul 10, 2017 Jul 10, 2017

again, the problem is that you did NOT place the problematic instance in frame 1 and assign its instance name and only then add subsequent keyframes.

or you did do that but you removed that instance in some keyframe and then replaced it.

Translate
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 ,
Jul 10, 2017 Jul 10, 2017
LATEST

I think the instance name and symbol library name can be the same without a problem.

Translate
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