我有内置的HTML / JavaScript的Adobe AIR应用程序。
I have an Adobe AIR application built in HTML/JavaScript.
中的XML如下:
<?xml version="1.0" encoding="UTF-8"?> <application xmlns="ns.adobe/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>
我要的是先显示一个启动画面,然后显示应用程序主窗口一旦所有的文件等加载。
What I want is to show a splash screen first and then show the main application window once all the files have loaded in etc.
一个想法是使在XML中的intialWindow文件实际的Web应用程序,但默认情况下使用其隐藏可见假则补充:
One idea was to make the intialWindow in the XML file the actual web app but then hide it by default using visible false then add:
$(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(); }); });
我有问题,这种方法是:
The questions I have with this approach are:
我已经开始有:
$(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 } }
一个问题与上面的code,就是appLoaded功能,可以运行几百次。任何建议解决这个?因为我想确保飞溅隐藏的仅仅是,一旦应用程序加载和飞溅已经出现。
One issue with the above code, is that the appLoaded function could run hundreds of times. Any suggestions for fixing this? As I want to make sure that the splash ONLY hides once the app has loaded and the splash has appeared.
推荐答案我做了类似的事情,但有另一种方法:
I did something similar but with another approach:
- 在我没有打开第二个窗口的启动画面,而是把闪屏的内容在里面的index.html一个div,并把它的实际内容之前。
- 我设置的初始宽度和高度闪屏的措施。
- 在该应用程序已经完全加载我删除从DOM闪屏股利,并设置宽度和高度应用的措施。
更新
我如何为闪屏的内容(我已经添加了一些code创建一个splash.html页面的窗口和负载,但它目前的假期,因为我相信,code是动作而不是JavaScript的)?
How do I provide the content for the splash screen (I've added some code to create a window and load in a splash.html page, but it currently breaks as I believe the code is ActionScript rather than JavaScript)?
第一:没有动作。这是JavaScript的,但你必须使用它以正确的方式。你错过了空气。从而重新presents库对象的空气。
First: There is no ActionScript. It's JavaScript but you have to use it in the right way. You missed air. which represents the library object for 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'));
关闭新的启动画面(我怎么选择关闭该窗口)?
Close the new splash screen (how do I choose which window to close)?
// That is your splash screen htmlLoader.window.nativeWindow.close();
显示负载正确的初始屏幕(如何选择正确的窗口)?
Show the correct initial screen on load (how do I choose the correct window)?
// This is your main window window.nativeWindow.visible = true;更多推荐
Adobe AIR的HTML闪屏
发布评论