1 Replies - 4093 Views - Last Post: 17 January 2014 - 02:26 AM

#1 James1992  Icon User is offline

  • D.I.C Head

Reputation: 3
  • View blog
  • Posts: 130
  • Joined: 30-October 12

How to add all button eventhandlers on frame one.

Posted 17 January 2014 - 02:01 AM

Right, so I currently get the following error:
TypeError: Error #1009: Cannot access a property or method of a null object reference

I've attached an image - might help you visualise my problem.

I currently have all my ActionScript stored within the first frame.
On the fourth frame I have some buttons.
I tried adding the following code on the first frame.
btnQ1A1.addEventListener(MouseEvent.CLICK, btnClickHandler2);


I believe the problem arises because the button I want to create a handler for doesn't exist in frame 1. I know I could solve this issue by having separate ActionScript on the fourth frame. However, I am wanting to pass variables around from frame to frame. So having separate frames of ActionScript isn't what I'm after.

Is it possible to somehow define a button even if it doesn't exist on frame 1?

Attached image(s)

  • Attached Image


Is This A Good Question/Topic? 0
  • +

Replies To: How to add all button eventhandlers on frame one.

#2 James1992  Icon User is offline

  • D.I.C Head

Reputation: 3
  • View blog
  • Posts: 130
  • Joined: 30-October 12

Re: How to add all button eventhandlers on frame one.

Posted 17 January 2014 - 02:26 AM

Solved it. For anyone who has the same problem this is what I did.

Just do all your eventlisteners on separate pages. For example, buttons that exist on frame 4 i'll write all the event listeners for them on frame 4. I can still call the function on frame 1 as usual.
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1