lqxue

常用链接

统计

book

tools

最新评论

Accecing a field on a tab navigator

Default Accecing a field on a tab navigator

hi,


i have a tab navigator. in one of my functions i'm trying to reference a field which is located on the second tab.

If i click "ok" from the first tab, which calls the function, which references the field on a second tab, it gives me a runtime error. But if i click on the second tab, and go back to the first, and then click on "OK" it works.

What is going on? am i supposed to somehow declare taht field before referencing it? to make it active..?

any help greatly appreciated.

Thanks!


this is the error i'm getting:

TypeError: Error #1009: Cannot access a property or method of a null object reference.
MadamZuZu is offline   Reply With Quote
  #2

 
 
 
Default

The children of a TabNavigator aren't created until they're needed. In your case, only the contents of the first tab are actually created, because they're part of what's needed when the TabNavigator is first displayed. The contents of the second tab won't be instantiated until they need to be displayed, which is when the second tab is clicked on. That's why that error is being thrown until you click on the second tab. This process of only instantiating components as they are needed is called deferred instantiation.

To force the contents of the other tabs to be instantiated, try changing the creationPolicy property of the TabNavigator to be "all". This will cause all of the different tabs to be instantiated, regardless of having been clicked on.

In the Flex docs, check out Container.creationPolicy for more details.

ActionScript Code:
            
<mx:TabNavigator creationPolicy="all">

posted on 2010-03-14 11:34 lqx 阅读(208) 评论(0)  编辑  收藏


只有注册用户登录后才能发表评论。


网站导航: