在特定时间调用 flex initComplete

发布于 2024-09-04 07:14:53 字数 447 浏览 9 评论 0原文

下面是 Flex 中预加载器的完整函数的重写。

private function initComplete(e:Event):void
  {
   //dispatchEvent(new Event(Event.COMPLETE));
   cp.status.text="Configuring... Please Wait";
  }

我想做的是,当应用程序完成加载时,我想将预加载器文本更改为“配置”。 然后我想在我的代码中做一些设置。

一旦我完成了我想要的所有设置,如何让预加载器从代码中的其他位置分派其 Event.complete ?

我尝试了 Application.application.preloader 但它显示为空。

所以我想我的问题实际上是如何从应用程序中的任何位置访问预加载器。 更好的方法是将所有安装类作为我的预加载器类的成员吗?

Below is the overriden on complete function for a preloader in Flex.

private function initComplete(e:Event):void
  {
   //dispatchEvent(new Event(Event.COMPLETE));
   cp.status.text="Configuring... Please Wait";
  }

What I want to do is when the app has finsihed loading I want to change the preloaders text to "configuring".
Then I want to go and do a bunch of setup stuff in my code.

Once I've done all the setup I wanted how can I get the Preloader to dispatch its Event.complete from else where in my code?

I tried Application.application.preloader but it comes up null.

So I guess my question really is how to access a preloader from anywhere in my application.
Would a better approach be to have all setup classes as members of my preloader class?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

少女净妖师 2024-09-11 07:14:53

可能有帮助的一件事是模型-视图-控制器模式。您的应用程序是否使用 Mate、Swiz 或 Cairngorm 等框架?

例如,如果您使用 Mate,您可以执行以下操作:

  • 创建一个带有属性的AppStateManager 类(例如applicationState)
  • 为FlexEvent.INITIALIZE 事件创建一个带有EventHandler 的EventMap。在此处理程序中,将 AppStateManager.applicationState 设置为类似“CONFIGURING”的内容。
  • 您的 EventMap 有一个注入器,可将 applicationState 属性注入到视图中。注入器侦听此属性的更改并更新视图。在这种情况下,它可能只是被注入到您的主视图中。
  • 在主视图中,您有一个公共可绑定属性,也称为 applicationState,由 Mate 注入。
  • 在此属性的设置器中,您可以有一个 if/then 或一个开关,根据状态执行不同的任务。例如,如果 applicationState == "COMPLETE",则 this.preloader.dispatchEvent(Event.COMPLETE) 或类似的东西。

详细信息是伪草图,但其想法是使用 Flex 的绑定在发生更改时通知视图组件,并让共享对象维护状态。不确定这是否是您要找的......

One thing that might help is a Model-View-Controller pattern. Are you using a framework for your application like Mate, Swiz, or Cairngorm?

If you were using Mate, for example, you could do something like this:

  • Create an AppStateManager class with a property (e.g. applicationState)
  • Create an EventMap with an EventHandler for the FlexEvent.INITIALIZE event. In this handler, set the AppStateManager.applicationState to something like "CONFIGURING"
  • Your EventMap has an injector that injects the applicationState property into a view. The injector listens for changes to this property and updates the view. In this case it might just be injected into your main view.
  • In the main view, you have a public bindable property also called applicationState that gets injected by Mate.
  • In the setter for this property, you can have an if/then or a switch that does different tasks depending on the state. For example, if applicationState == "COMPLETE", then this.preloader.dispatchEvent(Event.COMPLETE) or something like that.

The details are pseudo-sketched out but the idea is to use Flex's bindings to notify view components when changes have been made, and to have shared objects that maintain state. Not sure if that's what you're looking for...

烦人精 2024-09-11 07:14:53

组件 LifeCycle 按特定顺序执行特定操作,最后的元素是使组件可见。

在我看来,您想将可见设置推迟到 true 来执行其他操作。但是,我想如果您使用 LifeCycle 组件,这将不是问题。

您需要执行什么类型的应用程序初始化操作?

The component LifeCycle does specific stuff in a specific order, and the near final element is to make the component visible.

It sounds to me like you want to defer this setting of visible to true to do other stuff. But, I imaging if you were making use of the component LifeCycle this would be a non-issue.

What sort of app init stuff do you need to do?

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文