Flex 预加载器必须可见,直到加载其他外部文件

发布于 2024-11-15 02:00:00 字数 225 浏览 2 评论 0原文

我有一个 Flex 应用程序,可以从数据库加载一些数据。在此期间,我希望我的自定义预加载器保持可见。

困境是:当我在 FlexEvent.INIT_COMPLETE 处理程序中推迟 dispatchEvent(new Event(Event.COMPLETE)) 时,加载永远不会发生,因为下一帧不存在进入。

如何保持加载程序运行直到所有数据完全加载?

I have a Flex application that loads some data from the database. During this I want my custom preloader stay visible.

The dilemma is: When I postpone the dispatchEvent(new Event(Event.COMPLETE)) in the FlexEvent.INIT_COMPLETE handler, the loading will never happen because the next frame is not entered.

How can I keep the loader running until all the data is fully loaded?

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

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

发布评论

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

评论(1

狼亦尘 2024-11-22 02:00:00

预加载器基本上是一个精灵。所有 Flex 组件都会扩展精灵,因此您实际上可以轻松地继续使用精灵。我不确定覆盖应用程序框架中删除预加载精灵的部分有多困难。但是,我认为您可以使用自定义组件将精灵添加回舞台。

您可能必须创建一个 UIComponent 并添加预加载器组件,以便可以将其与状态一起使用。然后将您的新 UIComponent 设置为默认状态。

以下是我的“伪”代码。

public class MyFlexPreLoader extends UIComponent{

     private var var preloader:YourBasePreLoader; //This is the preloader you're already using

     override protected function createChildren(){
           //Add the Preloader here! 
           preloader = new YourBasePreLoader();
           addChild(preloader);
     }
     //Also add event listeners to manipulate your preloader to show the progress of loading stuff from DB
}

然后在您的应用程序中

<comp:MyFlexPreLoader includeIn="preloading"/>

,当您完成后,将应用程序的 currentState 更改为预加载。您可能需要重写 UIComponent 中的更多方法才能使其正常工作。

A preloader is basically a sprite. All flex components extend sprites so you can actually continue to work with sprites pretty easily. I'm not sure how difficult it would be to override the part of the application framework that REMOVES that pre-loader sprite.. however, I think you can add the sprite back to the stage... using a custom component .

You probably have to create a UIComponent and add your preloader component so that you can use it with states. Then set your NEW UIComponent to the default state.

The following is "psuedo" code off the top of my head.

public class MyFlexPreLoader extends UIComponent{

     private var var preloader:YourBasePreLoader; //This is the preloader you're already using

     override protected function createChildren(){
           //Add the Preloader here! 
           preloader = new YourBasePreLoader();
           addChild(preloader);
     }
     //Also add event listeners to manipulate your preloader to show the progress of loading stuff from DB
}

Then in your app

<comp:MyFlexPreLoader includeIn="preloading"/>

Now when you're done change the currentState of the app away from pre-loading. You may need to override a few more methods in UIComponent to get it working right.

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