繁体   English   中英

Adobe AIR HTML启动画面

[英]Adobe AIR HTML Splash Screen

我有一个内置HTML / JavaScript的Adobe AIR应用程序。

XML如下:

<?xml version="1.0" encoding="UTF-8"?>
<application xmlns="http://ns.adobe.com/air/application/4.0">
    <id>examples.html.HelloWorld</id>
    <versionNumber>0.1</versionNumber>
    <filename>HelloWorld</filename>
    <initialWindow>
        <title>Hello World</title>
        <content>HelloWorld.html</content>
        <visible>false</visible>
        <minimizable>true</minimizable>
        <maximizable>false</maximizable>
        <resizable>false</resizable>
        <width>800</width>
        <height>600</height>
        <systemChrome>none</systemChrome>
        <transparent>true</transparent>
    </initialWindow>
</application>

我想要的是先显示一个初始屏幕,然后在所有文件加载完毕后显示主应用程序窗口。

一种想法是使XML文件中的intialWindow成为实际的Web应用程序,但默认情况下使用visible false将其隐藏,然后添加:

$(document).ready(function(){

    // Create a new window that will become the splash screen
    var options = new air.NativeWindowInitOptions(); 
    options.systemChrome = air.NativeWindowSystemChrome.STANDARD; 
    options.transparent = false; 
    var newWindow = new air.NativeWindow(options);

// Add content to new window
var htmlView:HTMLLoader = new HTMLLoader(); 
htmlView.width = 300; 
htmlView.height = 500;  
newWindow.stage.align = "TL"; 
newWindow.stage.scaleMode = "noScale"; 
newWindow.stage.addChild( htmlView );
htmlView.load( new URLRequest('splash.html') );

    // Check for loading of app
    $(window).load(function(){

        // Hide splash
        window.nativeWindow.close();

        // Activate the initial Window
        window.nativeWindow.activate(); 

    }); 

});

我对这种方法的疑问是:

  1. 如何为初始屏幕提供内容(我添加了一些代码来创建窗口并加载在splash.html页面中,但是由于我认为代码是ActionScript而不是JavaScript而目前无法使用)
  2. 关闭新的启动屏幕(如何选择要关闭的窗口)
  3. 在加载时显示正确的初始屏幕(如何选择正确的窗口)

我开始于:

$(window).load(function () {

    loaded = true;

});

function appLoaded()
{
    if(loaded)
    {
        // Hide splash
        window.nativeWindow.close();


        // Activate the initial Window
        window.nativeWindow.activate();
    }
    else
    {
        appLoaded(); // keep checking until the loaded becomes true
    }
}

上面的代码的一个问题是appLoaded函数可以运行数百次。 对解决这个问题有什么建议吗? 我想确保只有在应用程序加载并且启动画面出现后,启动画面才隐藏。

我做了类似的事情,但是有了另一种方法:

  • 我没有为启动屏幕打开第二个窗口,而是将启动屏幕的内容放在index.html内的div中,并将其放在实际内容之前。
  • 我将初始宽度和高度设置为初始屏幕尺寸。
  • 应用程序完全加载后,我从DOM中删除了初始屏幕div,并为应用程序设置了宽度和高度。

更新

如何为初始屏幕提供内容(我添加了一些代码来创建窗口并加载在splash.html页面中,但是由于我认为代码是ActionScript而不是JavaScript而目前无法使用)?

第一:没有ActionScript。 它是JavaScript,但是您必须以正确的方式使用它。 你错过了空气。 代表Air的库对象。

// Create a new window that will become the splash screen
var options = new air.NativeWindowInitOptions(); 
options.systemChrome = air.NativeWindowSystemChrome.STANDARD; 
options.transparent = false; 

// Add content to new window
var htmlLoader = air.HTMLLoader.createRootWindow(false, options, false);    
htmlLoader.window.nativeWindow.width = 300;
htmlLoader.window.nativeWindow.height = 500;
htmlLoader.window.nativeWindow.visible = true;
htmlLoader.load(new air.URLRequest('splash.html'));

关闭新的启动屏幕(如何选择要关闭的窗口)?

// That is your splash screen
htmlLoader.window.nativeWindow.close();

在加载时显示正确的初始屏幕(如何选择正确的窗口)?

// This is your main window
window.nativeWindow.visible = true;

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM