tags:

views:

37

answers:

1

I have extended an mxml component with an actionscript class. I'm trying to access a component in the mxml file using the id (in order to add an event listener) but I cant seem to do it.

I get:

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

Anyone know what I'm doing wrong?

+1  A: 

Where exactly in your code are you trying to access the component? If it's before createChildren() is called, it won't exist yet.

If you're not familiar with the flex component lifecycle, you'll need to learn about it, it's an integral part of developing efficient flex components.

quoo
Excellent. That was the issue. I was attempting to access the component immediately after super(); but it wasnt working. Now I have put the lines into a handler, and applied it to the creationComplete event. Working perfect. Thanks!