如何判断控件何时第一次可见?
我有一个包含 TabNavigator 控件的弹出窗口。加载弹出窗口时,选项卡会动态添加到 TabNavigator。有没有一种好方法可以从选项卡本身判断何时加载其中一个选项卡?
我有一个需要进行服务调用的选项卡,并且我不希望进行服务调用,除非用户实际单击该选项卡来查看它。当 TabNavigator 索引更改时,我可以从弹出控件本身通知选项卡,但这似乎不是一个好方法。我想知道是否有一个事件或我可以挂钩的东西可以让我知道第一次需要渲染选项卡(从选项卡控件本身内部)。提前致谢!
I have a popup that contains a TabNavigator control. The tabs are dynamically added to the TabNavigator when the popup loads. Is there a good way to tell when one of the tabs is loaded, from the tab itself?
I have a tab that requires a service call to be made, and I don't want the service call to be made unless the user actually goes and clicks the tab to view it. I could notify the tab from the popup control itself when the TabNavigator index was changed, but that doesn't seem like a good way to go about doing it. I'm wondering if there's an event or something I could hook to that would let me know the tab needed to be rendered for the first time (from within the tab control itself). Thanks in advance!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
我想我不太明白这个问题,所以我再尝试一下。我认为这段代码可以解决您的问题。
诀窍是将组件的创建策略设置为“无”。 Flex 将创建选项卡,但不会创建组件本身。
I think I didn't quite understand the question, so I'm trying again. I think this code will address your problem.
The trick is setting the creation policy to "none" for the component. Flex will create the tab, but not the component itself.
有一个名为“FlexEvent.SHOW”的事件应该适合您。请参阅:http://help.adobe .com/en_US/FlashPlatform/reference/actionscript/3/mx/events/FlexEvent.html#SHOW
您可以将其放在 TabNavigator 上。即
或者你可以将它放在你的组件中。即,
如果您设置了创建策略,您也可以在创建完成时执行此操作,但只会在第一次创建选项卡时发生。
运行示例:
使用动态选项卡。
There's an event called the "FlexEvent.SHOW" event which should work for you. See: http://help.adobe.com/en_US/FlashPlatform/reference/actionscript/3/mx/events/FlexEvent.html#SHOW
You can put this on the TabNavigator. i.e.
Or you can put it inside your component. i.e.
If you're creation policy is set, you can also do this on creationComplete, but it will only happen the FIRST time the tab is created.
Running example:
With dynamic tabs.
阅读 Flex 组件生命周期。根据您的描述,我可能会监听选项卡内容上的creationComplete 事件。
Read up on the Flex Component LifeCycle. Based on what you describe, I would probably listen for the creationComplete event on the tab's content.