Skip to main content
February 14, 2013
Answered

Button inside MovieClip don't work...?!

  • February 14, 2013
  • 1 reply
  • 449 views

Hello,

I\m traying to create AIR for Android app & I have 2 MovieClips in the main timeline the first in frame 35 and the second in frame 99 with the name of quary_mc. Inside the second movieclip there is a button with the name of sID_btn. When i addEventListener in frame 1 of the  main timeline it display:

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

This is the code:

quary_mc.sID_btn.addEventListener(MouseEvent.CLICK, displayData);

function displayData(evt:MouseEvent):void

{

          trace("Hello");

}

Regards,

This topic has been closed for replies.
Correct answer Nabren

You will be unable to add the event listener to the button until frame 99 when it actually exists.

Alternatively, you can just add the button on frame 1 at an alpha of 0 and then set it to 1 at frame 99. However, it will still get mouse input so you will need to set quary_mc.visible = false on frame 1 and quary_mc.visible = true on frame 99 to solve that issue.

1 reply

Nabren
NabrenCorrect answer
Inspiring
February 14, 2013

You will be unable to add the event listener to the button until frame 99 when it actually exists.

Alternatively, you can just add the button on frame 1 at an alpha of 0 and then set it to 1 at frame 99. However, it will still get mouse input so you will need to set quary_mc.visible = false on frame 1 and quary_mc.visible = true on frame 99 to solve that issue.

February 14, 2013

Thanks Nabren

I just add the event handler to frame 99