Flex:将数据从预加载器传递到应用程序?

发布于 2024-08-18 20:21:21 字数 145 浏览 5 评论 0原文

我想跟踪下载和初始化我的 Flex 应用程序的客户体验。 (a) 有没有办法将数据从预加载器传递到应用程序?我想传递下载所需的时间和初始化所需的时间。 (b) 或者: 应用程序级别是否有与预加载器事件相对应的事件: 1.下载完成 2. 初始化完成(与应用程序创建完成相同)

I would like to track the customer experience in downloading and initializing my flex app.
(a) Is there a way to pass data from preloader to the application? I would like to pass the time it takes to download and the time it takes to initialize.
(b)Alternatively:
Is there an event at the application level that corresponds to the preloader events:
1. Download complete
2. Initialization complete (same as Application creationComplete)

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

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

发布评论

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

评论(1

回忆凄美了谁 2024-08-25 20:21:21

“显示应用程序的下载进度”

根据该文档,我会做这样的事情:

  • 创建 DownloadProgressBar 的一个简单子类,
  • 覆盖事件侦听器以跟踪下载/初始化期间经过的时间量,
  • 将时间值存储为静态属性,以便您可以访问它们一旦完成初始化,就可以从您的应用程序中获取。

这是我的想法的一个例子(我没有编译这段代码,更多的是为了让我了解我在说什么)。

package
{
public class TimedProgressBar extends mx.preloaders.DownloadProgressBar
{
    public static var startTime:Number = 0;
    public static var downloadCompleteTime:Number = 0;
    public static var RSLCompleteTime:Number = 0;

    public function TimedProgressBar() 
    {
        super();
        startTime = getTimer();
    }

    override protected function completeHandler(event:Event):void
    {
        super();
        downloadCompleteTime = getTimer();
    }

    override protected function rslCompleteHandler(event:RSLEvent):void
    {
        super();
        RSLCompleteTime = getTimer();
    }
}
}

将其设置为 Application.mxml 中的预加载器并侦听 APPLICATION_COMPLETE 事件:

<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" 
    preloader="TimedProgressBar"
    applicationComplete="applicationCompleteHandler(event)">


private function applicationCompleteHandler(event:FlexEvent):void
{
    var completeTime:Number = getTimer();

    var downloadTime:Number = TimedProgressBar.downloadCompleteTime - TimedProgressBar.startTime;
    var rslDownloadTime:Number = TimedProgressBar.RSLCompleteTime - TimedProgressBar.downloadCompleteTime;
    var totalInitTime:Number = completeTime - TimedProgressBar.startTime;

    // Do whatever logging you want with this information.
}

The "Showing the download progress of an application" article in the livedocs should help.

Based on that documentation, I would do something like this:

  • create a simple subclass of the DownloadProgressBar,
  • override the event listeners to track the amount of time that has elapsed during download/initialisation,
  • store the time values as static properties so you can access them from your Application once it's completed initialisation.

Here is an example of what I'm thinking (I've not compiled this code, it's more to give an idea of what I'm talking about).

package
{
public class TimedProgressBar extends mx.preloaders.DownloadProgressBar
{
    public static var startTime:Number = 0;
    public static var downloadCompleteTime:Number = 0;
    public static var RSLCompleteTime:Number = 0;

    public function TimedProgressBar() 
    {
        super();
        startTime = getTimer();
    }

    override protected function completeHandler(event:Event):void
    {
        super();
        downloadCompleteTime = getTimer();
    }

    override protected function rslCompleteHandler(event:RSLEvent):void
    {
        super();
        RSLCompleteTime = getTimer();
    }
}
}

Set that as your preloader in your Application.mxml and listen for the APPLICATION_COMPLETE event:

<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" 
    preloader="TimedProgressBar"
    applicationComplete="applicationCompleteHandler(event)">


private function applicationCompleteHandler(event:FlexEvent):void
{
    var completeTime:Number = getTimer();

    var downloadTime:Number = TimedProgressBar.downloadCompleteTime - TimedProgressBar.startTime;
    var rslDownloadTime:Number = TimedProgressBar.RSLCompleteTime - TimedProgressBar.downloadCompleteTime;
    var totalInitTime:Number = completeTime - TimedProgressBar.startTime;

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