Adobe AIR - 带有图像的自定义预加载器 [英] Adobe AIR - Custom Preloader with Image

查看:20
本文介绍了Adobe AIR - 带有图像的自定义预加载器的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

各位,

我设计了一个 Adobe AIR 应用程序.我想在它打开之前显示一些 preloader.

I have designed an Adobe AIR application. I want to show some preloader on it, before it opens up.

谁能通过preloader专门针对AIR或任何已经内置的教程来指导我?

Can anyone guide me with tutorials on preloader aimed for AIR specifically or any already built in ones?

谢谢

推荐答案

使用 AIR 我可以想到几种方法来实现:

With AIR I can think of a couple of ways to achieve that:

1.使用原生窗口

将主 WindowedApplication 的visible"属性设置为false".在 'creationComplete' 事件中生成一个包含启动画面的新窗口.在显示应用程序之前执行必要的逻辑.引导程序完成后,关闭初始屏幕并将主应用程序的可见"设置为真".

Set the 'visible' attribute of your main WindowedApplication to 'false'. On 'creationComplete' event spawn a new Window that contains your splash screen. Perform the necessary logic before showing the app. When the bootstrap is done close the splash screen and set the main appliation's 'visible' to 'true'.

2.在一个窗口中,使用状态

创建 2 个状态(例如正在加载"和正常").将主 WindowedApplication 的currentState"属性设置为loading".在这种状态下显示您的启动画面.在显示应用程序之前执行必要的逻辑.引导程序完成后,将currentState"属性设置为normal".在正常"状态下显示您的实际应用.

Create 2 states (e.g. 'loading' and 'normal'). Set the 'currentState' attribute of your main WindowedApplication to 'loading'. In this state display your splash screen. Perform the necessary logic before showing the app. When the bootstrap is done, set the 'currentState' attribute to 'normal'. In the 'normal' state display your actual application.

3.透明应用

使用透明的 AIR 应用程序,您可以使用状态(如 n° 2)和假窗口.您的主应用程序将是一个覆盖整个屏幕的透明窗口.您现在可以将启动画面和主视图放置在此透明窗口中的任何位置.不用担心:您可以点击透明窗口,因此不会被阻止.

With a transparent AIR application, you could work with states (as in n° 2) and fake windows. Your main application will then be a transparent window that covers the entire screen. You can now position the splash screen and the main view wherever you wish inside this transparent window. Don't worry: you can click through transparent windows so nothing will be blocked.

我可以向您展示一些代码,但我需要有关您的应用程序的更多具体信息.

I could show you some code, but I'd need more specific information about your application.

示例

最简单的解决方案是 nr 2:

The easiest solution would be nr 2:

<s:WindowedApplication xmlns:fx="http://ns.adobe.com/mxml/2009"
                       xmlns:s="library://ns.adobe.com/flex/spark"
                       xmlns:v="net.riastar.view"
                       currentState="loading"
                       creationComplete="boot()">

    <fx:Script>
        <![CDATA[
            private function boot():void {
                var bootstrap:Bootstrap = new Bootstrap();
                bootstrap.addEventListener(Event.COMPLETE, showApp);
                bootstrap.boot();
            }

            private function showApp(event:Event):void {
                currentState = 'normal';
            }
        ]]>
    </fx:Script>

    <s:states>
        <s:State name="loading" />
        <s:State name="normal" />
    </s:states> 

    <s:Image source="@Embed('splash.jpg')" includeIn="loading" />
    <v:MainView includeIn="normal" />

</s:WindowedApplication>

窗口示例

<s:WindowedApplication xmlns:fx="http://ns.adobe.com/mxml/2009"
                       xmlns:s="library://ns.adobe.com/flex/spark"
                       xmlns:v="net.riastar.view" 
                       creationComplete="showSplash()" 
                       visible="false">

    <fx:Script>
        <![CDATA[
            import mx.events.AIREvent;
            import spark.components.Window;

            private var splash:Window;

            private function showSplash():void {
                splash = new SplashWindow();
                splash.systemChrome = "none";
                splash.type = NativeWindowType.LIGHTWEIGHT;
                splash.addEventListener(AIREvent.WINDOW_COMPLETE, boot);
                splash.open();
            }

            private function boot(event:AIREvent):void {
                var bootstrap:Bootstrap = new Bootstrap();
                bootstrap.addEventListener(Event.COMPLETE, showApp);
                bootstrap.boot();
            }

            private function showApp(event:Event):void {
                callLater(splash.close);

                var mainWin:Window = new MainApplicationWindow();
                mainWin.open();
            }
        ]]>

    </fx:Script>

</s:WindowedApplication>

这个需要更多解释:在您的应用程序中,您必须将systemchrome"设置为none",将visible"设置为false",将transparent"设置为true".您还必须将可见"属性设置为假".这些设置将有效地隐藏主应用程序窗口.然后我们依次为启动画面和主视图创建一个窗口.主 WindowedApplication 保持不可见很重要,因为另一种方法会使该窗口在启动画面出现之前短暂可见(似乎是一个错误).

This one requires more explanation: in your application you'll have to set 'systemchrome' to 'none', 'visible' to 'false' and 'transparent' tot 'true'. You also have to set the 'visible' attribute to 'false'. These settings will effectively hide the main application window. We then sequentially create a window for the splash screen and one for the main view. It is important that the main WindowedApplication stays invisible, because another approach would make that window briefly visible before the splash screen shows up (seems to be a bug).

这篇关于Adobe AIR - 带有图像的自定义预加载器的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆