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

1120: Access of undefined property

New Here ,
Dec 12, 2014 Dec 12, 2014

Hi, I need a solution for my script for school assignment.

This is my codes:

stop();

var kanan:Boolean = false;

var kiri:Boolean = false;

var jumlah:int = 0;

var n=0;

var t=3;

kalah.visible = false;

mulai.addEventListener(MouseEvent.CLICK, mulaimain);

function mulaimain(event:MouseEvent):void

{

kalah.visible = false;

mulai.visible = false;

home.visible = false;

n=0; score.text=String(n);

t=3; lives.text=String(t);

stage.addEventListener (KeyboardEvent.KEY_DOWN, tekantombol);

stage.addEventListener (KeyboardEvent.KEY_UP, lepastombol);

cacto.addEventListener(Event.ENTER_FRAME,jalan);

taco.addEventListener(Event.ENTER_FRAME,jatuh);

heart.addEventListener(Event.ENTER_FRAME,jatuhhati);

function tekantombol (event:KeyboardEvent):void

{

  switch (event.keyCode)

  {

  case Keyboard.RIGHT :{kanan = true;break;}

  case Keyboard.LEFT :{kiri = true;break;}

  }

}

function lepastombol (event:KeyboardEvent):void

{

  cacto.gotoAndPlay(1);

  switch (event.keyCode)

  {

  case Keyboard.RIGHT :{kanan = false; jumlah=0;break;}

  case Keyboard.LEFT :{kiri = false; jumlah=0;break;}

  }

}

function jalan (event:Event) :void

{

  cacto.x+=jumlah;

  if (kanan){cacto.gotoAndStop(3); jumlah=11;}

  if (kiri){cacto.gotoAndStop(2); jumlah=-11;}

  if (cacto.x>=997){cacto.x=-10;}

  if (cacto.x<=-37){cacto.x=977;}

}

function jatuh(event:Event):void

{

  taco.y+=7;

  if(taco.y>=390)

  {

  t=t-1;lives.text=String(t);

  taco.y=-2;

  taco.x=Math.floor(Math.random()*800);

  }

  if(taco.hitTestObject(cacto))

  {

  n=n+1;score.text=String(n);

  taco.y=-2;

  taco.x=Math.floor(Math.random()*800);

  }

  if(t==0)

  {

  cacto.removeEventListener (Event.ENTER_FRAME,jalan);

  taco.removeEventListener (Event.ENTER_FRAME,jatuh);

  kalah.visible = true;

  mulai.visible = true;

  }

function jatuhhati(event:Event):void

{

  heart.y+=12;

  if(heart.y>=390)

  {

  heart.y=-30;

  heart.x=Math.floor(Math.random()*800);

  }

  if(heart.hitTestObject(cacto))

  {

  t=t+1;lives.text=String(t);

  heart.y=-30;

  heart.x=Math.floor(Math.random()*800);

  }

  }

}

}

Scene 1, Layer 'Actions', Frame 1, Line 261120: Access of undefined property jatuhhati.

and this Output:

ReferenceError: Error #1065: Variable TCMText is not defined.

Can somebody help me?

TOPICS
ActionScript
1.4K
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

correct answers 1 Correct answer

LEGEND , Dec 12, 2014 Dec 12, 2014

For the 1120 error you appear to have the jatuhhati function nested within another function.  The compiler cannot see it due to that.  You should never nest named functions within other functions.  Get it out on its own so that it can be seen when the listener assignment that uses it gets compiled.

As far as the 1065 error goes I cannot see any such object named in your code.  This usually makes me conclude that there is some component you are using that has such a textfield.

One thing yoiu should

...
Translate
LEGEND ,
Dec 12, 2014 Dec 12, 2014

For the 1120 error you appear to have the jatuhhati function nested within another function.  The compiler cannot see it due to that.  You should never nest named functions within other functions.  Get it out on its own so that it can be seen when the listener assignment that uses it gets compiled.

As far as the 1065 error goes I cannot see any such object named in your code.  This usually makes me conclude that there is some component you are using that has such a textfield.

One thing yoiu should always do when you start getting errors is to go into your Flash Publish Settings and select the option to Permit Debugging.  This can help by pointing to more specific information in the error messages you get, such as line numbers.

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 ,
Dec 13, 2014 Dec 13, 2014

Thank you very much! I moved my jatuhhati function out and it works. Thanks a lot, Ned!

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 ,
Dec 13, 2014 Dec 13, 2014
LATEST

You're welcome

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