actionscript-3 - StageWebView Flash 显示时为白色

标签 actionscript-3 flash air stagewebview

StageWebView Flash 显示时为白色

所以我一直在使用 Adob​​e Animate 创建一个通用 Air 应用程序,该应用程序可以移植到多个平台,即 Mac、Windows 和 iOS。

它使用 StageWebView 显示嵌入在 HTML 页面上的视频,这些页面具有自己的自定义 html5 视频播放器,除了一件简单但令人讨厌的事情外,一切都运行良好。

每当我显示 Stage Web View 时,您会在页面显示之前看到一闪而过的白色。

现在我最初认为这是检查 URL 加载完成或格式错误的 HTML 文档的问题,但似乎并非如此。

经过几次尝试消除该问题后,我确实注意到,如果我使用嵌入式 Air WebKit 而不是使用桌面设备中的 native WebKit,它确实会消失。

(下面的代码)在加载时导致白色闪烁:

var webView:StageWebView = new StageWebView(true);

(下面的代码)这解决了这个问题,但是嵌入式 WebKit 不支持我的 HTML 标签,如视频和进度,并且不再正常工作。
var webView:StageWebView = new StageWebView();

来自 Adob​​e 的设置信息:

useNative:Boolean (default = false) — When useNative is false, a version of WebKit embedded within AIR is used as the source of the StageWebView created. When useNative is true, then AIR will use the the system's default web engine. Mobile platforms only support using the system web engine, so useNative is ignored on mobile platforms.



令人沮丧的是,我设置了一个监听器来检查加载完成情况,但这并没有解决这个问题。因此,作为一种解决方法,我将显示的 StageWebView 隐藏在屏幕之外,然后在延迟后将其位置移动到我想要的位置,这不是很好。

其他尝试将其显示为小作为像素将其调整到位仍然会导致问题。
/*  Check for Stage Web View Errors */
webView.addEventListener(ErrorEvent.ERROR, onError);
function onError(e:ErrorEvent):void {
    trace("Stage Web View error: " + e);
}

/*  Function to not show Stage Web View until loaded.   */
function onCompleteHandler(e:Event):void {
    webView.assignFocus();
    // Delay the Stage Web View to fix white flash issue.
    setTimeout(callWebView,500);
    webView.removeEventListener(Event.COMPLETE,onCompleteHandler);
}

/*  Multi-Function Stage Web View Loader, Just add file path string to call */
function webviewFilePath(path:String):void {
    webView.stage = this.stage;
    // Prep filepath
    filePath = new File(new File(path).nativePath).url;
    // Load file path
    webView.loadURL(filePath);
    // Add listener for Complete URL Load then Show
    webView.addEventListener(Event.COMPLETE,onCompleteHandler);
}

/*  Function to call Stage Web View independantly so it can be delayed with a timer */
function callWebView() {
    webView.viewPort = new Rectangle(posX(viewX), posY(viewY), viewWidth, viewHeight);
}

关于如何缓解或解决问题的任何提示或提示都会很棒。

当然,如果 Adob​​e 真的更新了嵌入式 Air WebKit,这可能会首先解决整个问题,但我怀疑这很快就会发生。

部分修复

因此,当我最初加载舞台 Web View 时问题仍然存在,但我已设法在应用程序使用期间尽量减少其外观。

问题的一个主要部分是我如何重置 StageWebView 以准备我想要加载的新页面或当我想要关闭 View 时。

我在重置 StageWebView 时有点过火了,因为众所周知,即使 StageWebView 中的音频被隐藏,它也会继续播放。
/*  Function to Reset Stage Web View    */
function resetWebView():void {
    webView.loadString("<!DOCTYPE HTML><html><body></body></html>");
    //webView.viewPort = new Rectangle(0, 0, 0, 0);
    webView.stage = null;
    //webView.viewPort = null;
}

我意识到我可以简单地隐藏 StageWebView 并加载一个空白页面,同时它从 View 中隐藏以停止任何音频播放。这很容易通过加载一个简单的字符串来完成。

尽管有时我仍然会看到白色闪光,但它的发生率很小。

最佳答案

private var webView : StageWebView;

 webView  = new StageWebView( true );
 webView.stage = this.stage;
 webView.viewPort = new Rectangle( 0, 0, 1024, 768 );

关于actionscript-3 - StageWebView Flash 显示时为白色,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/40621238/

相关文章:

actionscript-3 - Flash 编译器/解释器优化

xml - 使用纯 AS3 创建 Android manifest xml

java - 在 Swing 中关闭 Flash 屏幕

jquery - 使用JQuery插入INPUT字段时如何控制表格单元格宽度

iphone - Adobe Air 与 Iphone

javascript - AS3 : Reading the DOM

actionscript-3 - as3中的定时器初始值

javascript - swfobject 不与 html 通信

java - 我应该使用 Flash 还是 Java?

air - 上传到 iTunesConnect 时出错