Skip to main content
Participant
August 3, 2009
Question

The Ole #1009: Cannot access a property or method of a null object reference ...

  • August 3, 2009
  • 1 reply
  • 626 views

To anyone that can help me I say thank you first I also say thank you to anyone else that attempts to help.  I am sure this will be an easy one for most of you but I am completely stumped.  I am a newbee to AS.

I have a movie that has navigation butttons and they all work find.  On a scene in the movie I have an image that grows grows from alpha 0 to 100%.  When you Mouse_Over the alpha drops to -.6 and when you Mouse_Out it goes back to 1.  I have this in frame 1 and this scene takes place between frames 115 and 166.  When I execute a Mouse.Click on the movieClip (contact_us_gel) I am moved to the emailScene.  The bad news is when I click the movieClip I get the below.  I change the movieClip to be on the stage for entire movie from frame 1 to 166 in hopes to loose this error.  As you can tell that didn't work.  Below is the AS code that I have written. I use this same code for my navigation buttons and I have no issues.  I have officially had my butt kicked by this one.

I have tried removing the eventListner and that just really messes me up until I go to the homeScene (frame 1) and add the event listner back for he contact_us_gel.

The Trace & Error from the outPut.....

Frame on Gel MouseOut 228 <<-- Trace statement when I click the gel / This is also where the email scene stars
TypeError: Error #1009: Cannot access a property or method of a null object reference.
    at barnumRealtyGroup_fla::MainTimeline/outCUG()[barnumRealtyGroup_fla.MainTimeline::frame1:131]

The code

//-- ContactUsGel --\\
contact_us_gel.addEventListener(MouseEvent.MOUSE_OVER,rolloverCUG);
contact_us_gel.addEventListener(MouseEvent.MOUSE_OUT,outCUG);
contact_us_gel.addEventListener(MouseEvent.CLICK,playHomeSceneCUG);

function rolloverCUG(event:MouseEvent):void{
contact_us_gel.alpha -= 0.6
}

function outCUG(evnt:MouseEvent):void{
    trace("Frame on Gel MouseOut "+this.currentFrame);
    contact_us_gel.alpha = 1; //this is where I am dying.... This is frame1:Line131
}

function playHomeSceneCUG(event:MouseEvent):void{
    trace("Frame on Gel Going to Email "+this.currentFrame);
    gotoAndPlay("emailScene");
}

Thank you in advance...

This topic has been closed for replies.

1 reply

kglad
Community Expert
Community Expert
August 3, 2009

contact_us_gel doesn't exist when outCUG() is called.

if you're convinced it does exist you probably have a different instance from the one that flash expects.  to remedy, clear all keyframes after the first one where contact_us_gel first is created.  retest.  any problems?

Participant
August 3, 2009

I follow you and something that I failed to mention is that this is happening only when I execute a MouseEvent.Click on contact_us_gel.  While looking at this after my post and testing what is happening is outCUG() is called during the MouseEvent.Click which calls playHomeSceneCUG() << takes me to emailScene.  That is what is killing me I have  not found a proper way to isolate that MouseEvent.Click and not allow it to call outCUG().  I know you are the GURU but did I confuse you.

kglad
Community Expert
Community Expert
August 3, 2009

actually, you're going to emailScene first and then trying to reference contact_us_gel.  and it's almost a certainty that when you direct the playhead to emailScene, the contact_us_gel that flash expects no longer exists.