Flex 中是否有 init() 方法,如 Servlet init() 只执行一次
Flex 具有任何 init()、destroy() 方法。就像 Servlet init() 方法将在应用程序初始化时运行,并且如果刷新页面也不会再次调用它。
Flex having any init(), destroy() method. Like Servlet init()method will run at Application initialize and never call it again if Refresh the Page also.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
我建议不要使用初始化事件,而使用creationComplete。所有 UIComponent 在完成自身及其子组件的构建后都会调度该事件。该事件在组件初始化、有机会测量自身、执行布局并添加到舞台后执行一次。
I would suggest not using initialize event, and instead use creationComplete. All UIComponent dispatch that event when they are finished constructing themselves AND their children. This event is executed once after the component has been initialized, had a chance to measure itself, perform layout, and added to the stage.
所有 Flex 组件,包括根“应用程序”组件,都有一个您可以监听和处理的“initlize”事件。
如果您希望它只运行一次,无论刷新如何,您都需要以某种方式存储变量,例如使用本地共享对象。这很容易做到:
All flex components, including the root "application" component have an "initlize" event that you can listen to and handle.
If you'd like it to only run ONCE, regardless of refresh, you'd need to store a variable somehow, such as with a local shared object. That's pretty easy to do: