Copy link to clipboard
Copied
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?
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.
Copy link to clipboard
Copied
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.
Copy link to clipboard
Copied
both of them exist, I used trace
mainMenu.tweenText.getChildByName("tween" + pageNum11 + pageNum1) is supposed to be a motion tween
Copy link to clipboard
Copied
which is line 82?
copy and paste both the trace statements in the context of your code and the trace output.
Copy link to clipboard
Copied
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?
Copy link to clipboard
Copied
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);
}
Copy link to clipboard
Copied
trace( mainMenu.tweenText.getChildByName("tween" + pageNum11 + pageNum1)) the output is null
trace(mainMenu.pane1.text1) the output is[object Text_24]
Copy link to clipboard
Copied
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.
Copy link to clipboard
Copied
getChildByName is supposed to be changed to get tween which function is that?
Copy link to clipboard
Copied
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).
Copy link to clipboard
Copied
thank you anyway guess have to remake the whole thing
Copy link to clipboard
Copied
you're welcome.
Find more inspiration, events, and resources on the new Adobe Community
Explore Now