-
1. Re: What is TypeError: Error #1009: Cannot access a property or method of a null object reference.
bhargavi reddy Aug 22, 2012 9:35 PM (in response to Kimlau1989)Once try to debug the program. You can get the line number where the error is. And trace the objects in that line, you can easily find out the null object.
For debug the program, go to Debug -> Debug Movie -> in Flash Professional.
-
2. Re: What is TypeError: Error #1009: Cannot access a property or method of a null object reference.
Kimlau1989 Aug 22, 2012 11:12 PM (in response to bhargavi reddy)var score:Number = 0;
var objectoriginalX2:Number;
var objectoriginalY2:Number;this.stop();
author.buttonMode = true;
author.addEventListener(MouseEvent.MOUSE_DOWN, pickupObject2);
author.addEventListener(MouseEvent.MOUSE_UP, dropObject2);doi.buttonMode = true;
doi.addEventListener(MouseEvent.MOUSE_DOWN, pickupObject2);
doi.addEventListener(MouseEvent.MOUSE_UP, dropObject2);year.buttonMode = true;
year.addEventListener(MouseEvent.MOUSE_DOWN, pickupObject2);
year.addEventListener(MouseEvent.MOUSE_UP, dropObject2);page.buttonMode = true;
page.addEventListener(MouseEvent.MOUSE_DOWN, pickupObject2);
page.addEventListener(MouseEvent.MOUSE_UP, dropObject2);volumn.buttonMode = true;
volumn.addEventListener(MouseEvent.MOUSE_DOWN, pickupObject2);
volumn.addEventListener(MouseEvent.MOUSE_UP, dropObject2);journal.buttonMode = true;
journal.addEventListener(MouseEvent.MOUSE_DOWN, pickupObject2);
journal.addEventListener(MouseEvent.MOUSE_UP, dropObject2);article.buttonMode = true;
article.addEventListener(MouseEvent.MOUSE_DOWN, pickupObject2);
article.addEventListener(MouseEvent.MOUSE_UP, dropObject2);function pickupObject2(event:MouseEvent):void {
event.target.startDrag(true);
event.target.parent.addChild(event.target);
objectoriginalX2 = event.target.x;
objectoriginalY2 = event.target.y;
}
function dropObject2(event:MouseEvent):void {
event.target.stopDrag();
var matchingTargetName:String = "target" + event.target.name;
var matchingTarget:DisplayObject = getChildByName(matchingTargetName);
if (event.target.dropTarget != null && event.target.dropTarget.parent == matchingTarget){
event.target.removeEventListener(MouseEvent.MOUSE_DOWN, pickupObject);
event.target.removeEventListener(MouseEvent.MOUSE_UP, dropObject);
event.target.buttonMode = false;
event.target.x = matchingTarget.x;
event.target.y = matchingTarget.y;
response_mc.gotoAndStop(1);
nextquestion.gotoAndStop(1);
score++
if ( score==7){
response_mc.gotoAndStop(2);
nextquestion.gotoAndStop(2);
nextquestion.addEventListener(MouseEvent.CLICK, question2);
function question2(event:MouseEvent):void{
gotoAndStop(3);
page.gotoAndStop(2);
volumn.gotoAndStop(2);
article.gotoAndStop(2);
journal.gotoAndStop(2);
year.gotoAndStop(2);
author.gotoAndStop(2);
doi.gotoAndStop(2);
}
}
} else {
event.target.x = objectoriginalX2;
event.target.y = objectoriginalY2;
}
}I use the debug to track.
it warns me that this code has error page.gotoAndStop(2);
but I don't know what is the error. -
3. Re: What is TypeError: Error #1009: Cannot access a property or method of a null object reference.
bhargavi reddy Aug 23, 2012 1:20 AM (in response to Kimlau1989)Now you have to check page object whether it is having frame 2 init or not.
-
4. Re: What is TypeError: Error #1009: Cannot access a property or method of a null object reference.
Kimlau1989 Aug 23, 2012 1:29 AM (in response to bhargavi reddy)It has frame2. all the objects have frame2. But debug warns all the objects such as page,volumn,article,journal,year,author,doi
-
5. Re: What is TypeError: Error #1009: Cannot access a property or method of a null object reference.
Ned Murphy Aug 23, 2012 4:22 AM (in response to Kimlau1989)Do all of those objects exist in frame 3 (gotoAndStop(3);) ? If not, you might try moving the gotoAndPlay(3) line after all the others.
-
6. Re: What is TypeError: Error #1009: Cannot access a property or method of a null object reference.
Cubs Win Remington Mar 17, 2013 7:32 PM (in response to Ned Murphy)Hello Ned,
I am also having the same issue. TypeError: Error #1009: Cannot access a property or method of a null object reference.
There is only one text field on the stage of the "CountDown" Scene which the following code is from. I have verified the instance name matches.
The object of this is to show a countdown and then to go to the next scene to start playing the game.
import flash.utils.Timer;
import flash.events.TimerEvent;
var countDownTimer:Timer = new Timer(1000);
countDownTimer.addEventListener(TimerEvent.TIMER, updateTimer);
countDownTimer.start();
var s:int = 5;
function updateTimer(event:TimerEvent):void{
var secondsCount:String = new String(s);
var time1:String = secondsCount;
time_txt.text = secondsCount;
if(s >= 0){
s--;
}
if(s <= 0){
gotoAndStop(1,"Game");
}
}
This is the full error message
TypeError: Error #1009: Cannot access a property or method of a null object reference.
at Grizzle_fla::MainTimeline/updateTimer()[Grizzle_fla.MainTimeline::frame2:17]
at flash.utils::Timer/_timerDispatch()
at flash.utils::Timer/tick()
any ideas?
-
7. Re: What is TypeError: Error #1009: Cannot access a property or method of a null object reference.
Ned Murphy Mar 17, 2013 8:06 PM (in response to Cubs Win Remington)Whatever object is being targeted in line 17 is the focal point of the error.
-
8. Re: What is TypeError: Error #1009: Cannot access a property or method of a null object reference.
Cubs Win Remington Mar 18, 2013 8:45 AM (in response to Ned Murphy)FOUND IT!!
Come to find out that I needed to remove the listener and stop the timer once the clock gets to zero. Basically once it went to the next stage, the clock was still ticking and it couldn't find the instance on the stage anymore. I may be wrong on the reasoning but thats the only thing I could think of that I hadn't already tried.
Guess I just needed to sleep on it.
-
9. Re: What is TypeError: Error #1009: Cannot access a property or method of a null object reference.
Nami Di Jun 12, 2014 9:31 AM (in response to bhargavi reddy)Thanks a lot!



