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

TypeError: Error #1009: Cannot access a property or method of a null object reference. at KKK25_fla::MainTimeline/qwe()[KKK25_fla.MainTimeline::frame4:50]

New Here ,
Jul 10, 2015 Jul 10, 2015

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

  at KKK25_fla::MainTimeline/qwe()[KKK25_fla.MainTimeline::frame4:50]

TOPICS
ActionScript
448
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 11, 2015 Jul 11, 2015

on line 50 of frame 4 of your main swf you're trying to reference (with actionscript) an object that doesn't exist (when your code executes).

Debugging ActionScript 3.0 Errors | Adobe Community

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 11, 2015 Jul 11, 2015

whats the best thing i would do?

here's the code

function qwe(e:Event){

  mcGdeJesus.y += 25 / stage.frameRate;

  mcMDizon.y += 28 / stage.frameRate;

  mcMAquino.y += 30 / stage.frameRate;

  mcTMagbanua.y += 42 / stage.frameRate;

  mcTTecson.y += 34 / stage.frameRate;

  mcJRizal.y += 36 / stage.frameRate;

  if(mcGdeJesus.y > stage.stageHeight + mcGdeJesus.height){

  mcGdeJesus.x = Math.random() * 450 + 450;

  mcGdeJesus.y = -mcGdeJesus.height

  }

  if(mcMDizon.y > stage.stageHeight + mcGdeJesus.height){

  mcMDizon.x = Math.random() * 450 + 450;

  mcMDizon.y = -mcMDizon.height

  }

  if(mcMAquino.y > stage.stageHeight + mcGdeJesus.height){

  mcMAquino.x = Math.random() * 450 + 450;

  mcMAquino.y = -mcMAquino.height

  }

  if(mcTMagbanua.y > stage.stageHeight + mcGdeJesus.height){

  mcTMagbanua.x = Math.random() * 450 + 450;

  mcTMagbanua.y = -mcTMagbanua.height

  }

  if(mcTTecson.y > stage.stageHeight + mcGdeJesus.height){

  mcTTecson.x = Math.random() * 450 + 450;

  mcTTecson.y = -mcTTecson.height

  }

  if(mcJRizal.y > stage.stageHeight + mcGdeJesus.height){

  mcJRizal.x = Math.random() * 450 + 450;

  mcJRizal.y = -mcJRizal.height

  }

  }

and when i click the button play, it goes error and here's the code for the button.

mcPlay.addEventListener(MouseEvent.CLICK, GameWOFMenu);

function GameWOFMenu(m:MouseEvent)

{

  gotoAndStop(1, "GameMenu");

}

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 11, 2015 Jul 11, 2015

which is line 50 of frame 4?

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 11, 2015 Jul 11, 2015

after function qwe(e:Event){

line 50 is   mcGdeJesus.y += 25 / stage.frameRate;

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 12, 2015 Jul 12, 2015

then mcGdeJesus doesn't exist when you see that error message.  ie, when you change scenes you go to another keyframe where you probably think mcGdeJesus exists, but it's not the same mcGdeJesus that existed before you changed scenes.  and flash doesn't know how to handle two different objects with the same reference.

the easiest remedy is don't use scenes.

if you don't do that, you'll need to assign that 2nd mcGdeJesus a different instance name and use that name at line 50 (eg, use a variable to store the mc's reference), or create a new function to reference that new object in GameMenu.

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 13, 2015 Jul 13, 2015

i used scenes to organize my animations.

but i dont need the mcGdeJesus etc. in the next scenes.

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 13, 2015 Jul 13, 2015
LATEST

then don't execute line 50 when you change scenes.

you can always use an if-statement (though that might not be the cleverest way to handle the problem);

if(this.currentScene.name!='GameMenu'){

mcGdeJesus.y += 25 / stage.frameRate;

}

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