Skip to main content
Known Participant
March 21, 2012
Question

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

  • March 21, 2012
  • 1 reply
  • 646 views

Hello -

Hoping someone can help me out.  This is for a banner ad.  Everything was working perfect until I added an invisible button to the first 315 frames and added the Link_1 clickTag code.  We use an ad server so I have to use the clickTag code that they provided for each external link.  I am not sure why it worked just fine before I added in the invisible button and now it does not.  I am wondering if the Fire Animation movie (see AS3 down below) is somehow comflicting with the button being overtop of it?

I used the Debugger and it says:

Scene/Symbol                              Layer                         Frame

Scene 1                                         AS3                            450

#MAIN_FIRE_CONTAINER          ActionScript               1

single_fire_animation                    SingleFire                   35

Here is my main AS3 on the main timeline - last frame (frame 450)

stop();

Link_1.addEventListener(MouseEvent.MOUSE_UP, function(event: MouseEvent): void {

var sURL: String;

if ((sURL = root.loaderInfo.parameters.clickTag)) {

navigateToURL(new URLRequest(sURL), "_blank");

}

});

Link_2.addEventListener(MouseEvent.MOUSE_UP, function(event: MouseEvent): void {

var sURL: String;

if ((sURL = root.loaderInfo.parameters.clickTag)) {

navigateToURL(new URLRequest(sURL), "_blank");

}

});

Link_3.addEventListener(MouseEvent.MOUSE_UP, function(event: MouseEvent): void {

var sURL: String;

if ((sURL = root.loaderInfo.parameters.clickTag)) {

navigateToURL(new URLRequest(sURL), "_blank");

}

});

Link_4.addEventListener(MouseEvent.MOUSE_UP, function(event: MouseEvent): void {

var sURL: String;

if ((sURL = root.loaderInfo.parameters.clickTag)) {

navigateToURL(new URLRequest(sURL), "_blank");

}

});

Link_5.addEventListener(MouseEvent.MOUSE_UP, function(event: MouseEvent): void {

var sURL: String;

if ((sURL = root.loaderInfo.parameters.clickTag)) {

navigateToURL(new URLRequest(sURL), "_blank");

}

});

legal.addEventListener(MouseEvent.CLICK, clickFunction);

function clickFunction(evt:MouseEvent):void {

gotoAndStop(341);

}

replay.addEventListener(MouseEvent.CLICK, onClick);

function onClick(event:MouseEvent):void

{

     gotoAndPlay(1); // plays the current timeline from 1

} // end of onClick

Here is the AS3 for the Fire Animation

var nr:Number = 0;

var $mc:MovieClip;

this.addEventListener(Event.ENTER_FRAME, enterHandler);

function enterHandler (evt:Event):void{

    if(nr < 100)

    {

            $mc = new Fire(); //assumes you have a movie clip with a class name of "Fire" set to export for AS

            $mc.x = (Math.random()*4)-2;

            $mc.scaleY = 0.80;

            $mc.rotation = (Math.random()*2)-1;

            Math.random()*2 > 1 ? $mc.scaleX = 0.80:$mc.scaleX = -0.80;

            this.addChild($mc);

            nr++;

    } else {

        nr = 0;

    }

}

Any help is greatly appreciated!!!!

Thank you!

This topic has been closed for replies.

1 reply

Ned Murphy
Legend
March 21, 2012

The 1009 error indicates that one of the objects being targeted by your code is out of scope.  This could mean that the object....

 

- is declared but not instantiated

- doesn't have an instance name (or the instance name is mispelled)

- does not exist in the frame where that code is trying to talk to it

- is animated into place but is not assigned instance names in every keyframe for it

- is one of two or more consecutive keyframes of the same objects with no name assigned in the preceding frame(s).

 

If you go into your Publish Settings Flash section and select the option to Permit debugging, your error message should have a line number following the frame number which will help you isolate which object is involved.

mdwebcatAuthor
Known Participant
March 21, 2012

Thank you.  I followed yoru instructions for the Publish Settings and then tested again.  It said:

MainTimeline::frame450:3

My AS3 is on frame 450 (the last frame)

Is the "3" the line of code in the AS3?  If so, this is where Link_1 starts.  Hmmm... everything looks okay to me but I will go through your helpful list again to see if I missed anything.

Thank you!!

mdwebcatAuthor
Known Participant
March 21, 2012

So, I was just experimenting...  If I re-size the invisible button down below the fire movie, it works.  I forgot to mention that I am also using a plugin called FlashEff2 for some of the text.  Maybe it is conflicting with that.  I will go onto their forums as well and see if I can find any solutions.