4 Replies - 480 Views - Last Post: 19 March 2011 - 05:32 AM

#1 gareth.nic  Icon User is offline

  • D.I.C Head

Reputation: 23
  • View blog
  • Posts: 102
  • Joined: 22-October 10

TypeError #1009 hates me...

Posted 15 March 2011 - 12:33 PM

I keep getting this error. I've tried everything, googled everything and I can't find the solution. This error message doesn't help much, because I've done the movieclip (used as button) the same way as all the others. The button in question is in a layer called buttons, but in a different frame.

The error message when debugging:

TypeError: Error #1009: Cannot access a property or method of a null object reference.
	at cct_fla::MainTimeline/frame1()[cct_fla.MainTimeline::frame1:43]



import flash.events.MouseEvent;

mcHomeButton.buttonMode = true;
mcHomeButton.addEventListener(MouseEvent.CLICK,showHome);

function showHome (e:MouseEvent):void
{
	gotoAndPlay("Home");
}

mcHistoryButton.buttonMode = true;
mcHistoryButton.addEventListener(MouseEvent.CLICK,showHistory);

function showHistory (e:MouseEvent):void
{
	gotoAndPlay("History");
}

mcWhyFETButton.buttonMode = true;
mcWhyFETButton.addEventListener(MouseEvent.CLICK,showWhyFET);

function showWhyFET (e:MouseEvent):void
{
	gotoAndPlay("WhyFET");
}

mcContactUsButton.buttonMode = true;
mcContactUsButton.addEventListener(MouseEvent.CLICK,showContactUs);

function showContactUs (e:MouseEvent):void
{
	gotoAndPlay("Contact Us");
}

mcFinancesButton.buttonMode = true;
mcFinancesButton.addEventListener(MouseEvent.CLICK,showFinances);

function showFinances (e:MouseEvent):void
{
	gotoAndPlay("Finances");
}

mcFinancesNextButton.buttonMode = true; //line 43 causing trouble.
mcFinancesNextButton.addEventListener(MouseEvent.CLICK,showFinancesNextText);

function showFinancesNextText (e:MouseEvent):void
{
	gotoAndPlay("FinancesNextText");
}


Is This A Good Question/Topic? 0
  • +

Replies To: TypeError #1009 hates me...

#2 Atli  Icon User is offline

  • D.I.C Lover
  • member icon

Reputation: 3712
  • View blog
  • Posts: 5,964
  • Joined: 08-June 10

Re: TypeError #1009 hates me...

Posted 15 March 2011 - 12:54 PM

View Postgareth.nic, on 15 March 2011 - 08:33 PM, said:

The button in question is in a layer called buttons, but in a different frame.

Is that frame later in the timeline than the frame where this code is?

Until the frame is reached, the objects on it don't exist.
Was This Post Helpful? 1
  • +
  • -

#3 gareth.nic  Icon User is offline

  • D.I.C Head

Reputation: 23
  • View blog
  • Posts: 102
  • Joined: 22-October 10

Re: TypeError #1009 hates me...

Posted 15 March 2011 - 02:23 PM

It is indeed. Didn't really think of that. Is there a way around it. I want that button to display only when the user clicks on a certain page. It's gonna work as a "more" button, to display extra info.

Would inserting it in the first frame and setting alpha to 0 work? Then just making it visible when needed?

Thanks for the response. Much appreciated.
Was This Post Helpful? 0
  • +
  • -

#4 Atli  Icon User is offline

  • D.I.C Lover
  • member icon

Reputation: 3712
  • View blog
  • Posts: 5,964
  • Joined: 08-June 10

Re: TypeError #1009 hates me...

Posted 15 March 2011 - 02:44 PM

Yea, that could work.

You can also just do clip.visible = false; in the beginning and then set it to true when you want it visible.
Was This Post Helpful? 1
  • +
  • -

#5 gareth.nic  Icon User is offline

  • D.I.C Head

Reputation: 23
  • View blog
  • Posts: 102
  • Joined: 22-October 10

Re: TypeError #1009 hates me...

Posted 19 March 2011 - 05:32 AM

Thanks man! Tried it and it worked. :)
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1