Skip to main content
Inspiring
October 15, 2008
Question

addEventListiner to a different MC

  • October 15, 2008
  • 3 replies
  • 586 views
Hello,
I am having trouble with adding event listeners to a different parent MovieClip. It seems so simple, but I cannot seem to get it right... I am receiving the following error:

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

Thanks,
Jake
This topic has been closed for replies.

3 replies

Inspiring
October 16, 2008
Hello,

http://curtismorley.com/2007/08/15/flash-cs3-flex-error-1009-cannot-access-a-property-or-method-of-a-null-object-reference/

This website helped me solve my problem. The problem was that the code from the class was loaded before my button was, causing an error that the reference to the button was not valid or null. To solve this I used the following method:

addEventListener(MouseEvent.MOUSE_MOVE, init);

public function init(event:MouseEvent):void
{
//listeners added here
}

-Jake
Inspiring
October 16, 2008
okayPlay is a button that should activate a movieclip on the stage to play();. okayPlay is located on the stage. The code above is located in an extended class attached to a movieclip within the movieclip that I want to play when okayPlay is CLICKed. The movieclip with the class extended moves around via motion tween (I don't know if that is relevant). I have other functions (like a stoping function) that are set up the same way and do not work. I did a debuging and it told me the line with the addEventListener was at fault.

Thanks again,
-Jake
Inspiring
October 15, 2008
Hi,

I think it would be in your best interest, if you could provide your code ;)

Kind Regards,

Boxing Boom
Inspiring
October 15, 2008
code now provided:
Inspiring
October 15, 2008
Hi,

I am sorry but your code doesn't make any sense to me; what is the playIt function - it's purpose and where is it's code?

Describe your fla in greater detail; i.e. okPlay is obviously on the stage. Contained within what?

i.e. container.okPlay

What does the other MovieClip contain or do, and what code was used within?

Kind Regards,

Boxing Boom