Flex 应用程序加载和同步性
我知道有很多关于 Flex 同步性的问题,但我不确定是否有任何问题涵盖了我遇到的相同问题。标题仅指我一直在寻求的一种可能的解决方案,但本质上这是我的情况:
假设我有一个 Flex 应用程序,并且我有一个 XML 文件,其中包含我想要加载到该应用程序中的配置设置,最好是在运行时加载 -时间(虽然我对编译时也很好,但找不到一种方法来做到这一点,因为“-define”命令行参数只会实例化字符串、数字和布尔值,而且我有一些更复杂的配置结构 - 我也不能仅仅在 Flex 中将它们创建为一堆常量,因为它们被用在许多其他地方)。
但是,其中一些配置设置在加载时也会在应用程序的各个子项中使用,因此在加载这些容器之前无法执行并完成加载(由于异步性 - 这些子项在配置仍然存在时加载)使用事件侦听器和处理程序加载并解析;当然,在处理程序完成之前,子组件已经被错误加载)。
有没有办法让这个配置文件在应用程序的子应用程序之前加载?或者甚至在应用程序本身之前?这种同步应用程序负载的方法只是一种可能的方法,但似乎没有其他方法效果更好。
I know there are a lot of questions that have been asked about synchronicity in Flex, but I'm not sure if any cover the same issue I'm having. The title only refers to one possible solution I've been going for with this, but essentially here's my situation:
Say I have a Flex application, and I have an XML file with configuration settings I want loaded into that application, preferably at run-time (Although I would've been fine with compile-time as well but can't find a way to do this as the "-define" command-line parameter will only instantiate strings, numbers, and Booleans and I have some more complex configuration structures - I also cannot merely create these as a bunch of constants in Flex because they are used in numerous other places).
However, some of these configuration settings are also used in the various children of the application when they load, so there's no way to perform and complete the load before these containers are loaded (Because of asynchronicity - these children are loaded while the configuration is still being loaded in and parsed using an event listener and handler; of course, before the handler completes, the children components are already loaded incorrectly).
Is there any way to get this configuration file to load before the application's children do? Or even before the application itself? This approach of synchronizing the application load is only one possible approach, but no other approaches seem to fare any better.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
我有一个“shell”应用程序,它的 MXML 中没有声明任何 UI 子项。在其创建完成处理程序上,我加载我的配置文件。一旦加载事件完成,我就会在 Actionscript 中实例化我的孩子。
I have a 'shell' Application that doesn't have any UI children declared in its MXML. On its creationComplete handler, I load my configuration file. Once that load event is completed, I instantiate my children in Actionscript.
如果这些“子项”对用户不可见,您可以推迟它们的初始化。
因此,加载配置后,触发一个事件,然后触发子项的初始化。这不会损害用户的感知。
If those 'children' are not visible the the user, you can defer their initialization.
So, after the config is loaded, trigger an event which then triggers the initalization of the children. This wouldn't imapair user perception.
与 Mike 的建议类似,您所需要做的就是拥有一个带有creationPolicy="none" 的容器(Canvas、VBox 等);当您准备好初始化应用程序时,可以在容器上调用 createComponentsFromDescriptors()。
另一种方法是将内容放入模块中,并在加载配置后加载它。
Similar to what Mike suggested, all you need to do is have a single Container (Canvas, VBox, etc) with creationPolicy="none"; when you are ready to initialize the application, you can call createComponentsFromDescriptors() on the Container.
Another approach would be put that content into a Module and load it after your configuration is loaded.