Christopher Odum
Christopher Odum

Reputation: 1

Getting a null object reference error for a button instance

I am trying to use this script to jump to a certain point on my timeline:

feature1_btn.addEventListener(MouseEvent.CLICK, feature1);
function feature1(event:MouseEvent):void {
    gotoAndPlay(620);
}

I have the instance of my button labeled as "feature1_btn". Why am I getting this error?

Upvotes: 0

Views: 753

Answers (1)

Brian Driscoll
Brian Driscoll

Reputation: 19635

You're likely getting this error because you're attempting to add the listener to the instance before the instance has been created and/or initialized. If this code is in your timeline you need to make sure that feature1_btn exists on the stage at that point in the timeline.

Upvotes: 1

Related Questions