How do I add an event listener to a button inside a tab navigator (flex 4.5)?

I have a tab navigator defined in MXML, with two tabs. In each tab, I have some buttons. I have used ActionScript to add event listeners to all the buttons, and they work for the buttons that are visible (and in the currently "active" tab) when I load my Flex 4.5 AIR application.

However, I get an AIR error for the event listeners attached to the buttons in the second tab. Here's the crucial part of the error:

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

And when I test out my application, sure enough, there are no event listeners attached to the buttons in the second tab.

How can I fix this?


I think you need to set creationPolicyto 'all' on your TabNavigator. This is because, by default, Flex only initializes the screens that are actually visible. If you set your TabNavigator creationPolicy attribute to "all", all elements will be initialised, even if they are not visible.

Need Your Help

Reuse aggregate function value multiple times in the same query in sql

sql sql-server

I am working on a transaction report export from our system to another, and have a query like the following

Reverse DNS Lookup from a list of values - Python

python python-3.x dns reverse-dns

i am trying to do a DNS lookup to an IP with Python, im using Python 3.x.