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.

Guest
Jan 26, 2013 Jan 26, 2013

error:

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

          at test1_fla::MainTimeline/openPage1()[test1_fla.MainTimeline::frame2:82]

at test1_fla::MainTimeline/onClickBtn1()[test1_fla.MainTimeline::frame2:52]

code:

line 77 -83:

function openPage1():void

{

          var pageNum11:int;

          pageNum11 = pageNum1 - 1;

          trace("tween" + pageNum11 + pageNum1);

          mainMenu.tweenText.getChildByName("tween" + pageNum11 + pageNum1).addTarget(mainMenu.pane1.text1, 1);

}

line 46-59:

function onClickBtn1(e:MouseEvent):void

{

          switch(e.target)

          {

                    case mainMenu.pane1.btnDown:

                              pageNum1 += 1;

                              openPage1();

                              break;

                    case mainMenu.pane1.btnUp:

                              openPage1();

                              pageNum1 -= 1;

                              break;

          }

}

Can anyone tell me where did I do wrong?

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

Community Expert , Jan 26, 2013 Jan 26, 2013

ok, so mainMenu.tweenText.getChildByName("tween" + pageNum11 + pageNum1) doesn't exist for the variable values that were assigned at the time the trace returned null.  fix that.

Translate
Community Expert ,
Jan 26, 2013 Jan 26, 2013

if line 82 is the addTarget line, then either

  mainMenu.tweenText.getChildByName("tween" + pageNum11 + pageNum1)

or

mainMenu.pane1.text1

don't exist when that code executes.  use the trace function to determine which.

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
Guest
Jan 26, 2013 Jan 26, 2013

both of them exist, I used trace

mainMenu.tweenText.getChildByName("tween" +  pageNum11 + pageNum1) is supposed to be a motion tween

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 ,
Jan 26, 2013 Jan 26, 2013

which is line 82?

copy and paste both the trace statements in the context of your code and the trace output.

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
Guest
Jan 26, 2013 Jan 26, 2013

function openPage1():void

{

          var pageNum11:int;

          pageNum11 = pageNum1 - 1;

          trace("tween" + pageNum11 + pageNum1);

          mainMenu.tweenText.getChildByName("tween" + pageNum11 + pageNum1).addTarget(mainMenu.pane1.text1, 1);

}

that's the trace 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
Community Expert ,
Jan 26, 2013 Jan 26, 2013

no, that tells you nothing about whether those two objects exist.  use:

function openPage1():void

{

          var pageNum11:int;

          pageNum11 = pageNum1 - 1;

          trace("tween" + pageNum11 + pageNum1);

trace( mainMenu.tweenText.getChildByName("tween" + pageNum11 + pageNum1))

trace(mainMenu.pane1.text1)

          mainMenu.tweenText.getChildByName("tween" + pageNum11 + pageNum1).addTarget(mainMenu.pane1.text1, 1);

}

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
Guest
Jan 26, 2013 Jan 26, 2013

trace( mainMenu.tweenText.getChildByName("tween" + pageNum11 + pageNum1)) the output is null

trace(mainMenu.pane1.text1) the output is[object Text_24]

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 ,
Jan 26, 2013 Jan 26, 2013

ok, so mainMenu.tweenText.getChildByName("tween" + pageNum11 + pageNum1) doesn't exist for the variable values that were assigned at the time the trace returned null.  fix that.

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
Guest
Jan 26, 2013 Jan 26, 2013

getChildByName is supposed to be changed to get tween which function is that?

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 ,
Jan 26, 2013 Jan 26, 2013

i don't understand your question.  but then i don't understand most of what you're doing.

but if you are trying to reference a timeline tween, it's not an object so it can't be referenced using actionscript until it is converted into an object (ie, movieclip).

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
Guest
Jan 26, 2013 Jan 26, 2013

thank you anyway guess have to remake the whole thing

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 ,
Jan 26, 2013 Jan 26, 2013
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