首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >在StageWebViewBridge上加载本地html时出错

在StageWebViewBridge上加载本地html时出错
EN

Stack Overflow用户
提问于 2013-04-11 09:21:27
回答 2查看 901关注 0票数 1

当我试图在StageWebViewBridge容器上加载一个本地html时,我会得到这个错误:

错误#2044:未处理的ErrorEvent:。text=Load误差

代码:

代码语言:javascript
复制
private function onDiskCacheEnd( e:StageWebviewDiskEvent ):void{
    bridge = new StageWebViewBridge( 0, 0, 1280, 720 );
    bridge.loadLocalURL('applink://index.html');
...

index.html位于www文件夹中。

谢谢!

EN

回答 2

Stack Overflow用户

发布于 2014-02-25 02:03:51

实际上从未尝试过这种方法,但是文档(https://code.google.com/p/stagewebviewbridge/wiki/ContentLoading)只使用一个斜杠。

所以,而不是:'applink://index.html‘

文档使用:"applink:/index.html“

票数 0
EN

Stack Overflow用户

发布于 2014-05-27 05:56:04

这里,StageWebView不能引用您在loadURL()中给出的URL,因为applink是通过文档中的单个斜杠获得引用的。但我无法尝试使用applink。StageWebViewBridge在其覆盖保护的addEventListener函数中不处理ErrorEvent。如果需要处理此错误事件,则应添加

代码语言:javascript
复制
    override public function addEventListener( type : String, listener : Function, useCapture : Boolean = false, priority : int = 0, useWeakReference : Boolean = false ) : void
    {
        switch( type )
        {
            case ErrorEvent.ERROR:
            case Event.COMPLETE:
            case LocationChangeEvent.LOCATION_CHANGING:
            case LocationChangeEvent.LOCATION_CHANGE:
            case FocusEvent.FOCUS_IN:
            case FocusEvent.FOCUS_OUT:
                _view.addEventListener( type, listener, useCapture, priority, useWeakReference );
                break;
            default:
                super.addEventListener( type, listener, useCapture, priority, useWeakReference );
                break;
        }
    }

同时也需要删除监听器,

代码语言:javascript
复制
  override public function removeEventListener( type : String, listener : Function, useCapture : Boolean = false ) : void
    {
        switch( type )
        {
            case ErrorEvent.ERROR:
            case Event.COMPLETE:
            case LocationChangeEvent.LOCATION_CHANGING:
            case LocationChangeEvent.LOCATION_CHANGE:
            case FocusEvent.FOCUS_IN:
            case FocusEvent.FOCUS_OUT:
                _view.removeEventListener( type, listener, useCapture );
                break;
            default:
                super.removeEventListener( type, listener, useCapture );
                break;
        }
    }

现在您可以通过以下方式处理ErrorEvent

代码语言:javascript
复制
     webView.addEventListener( ErrorEvent.ERROR, onLoadURLErrorTriggered );

而且,您最好提供文件url来加载本地html文件,

代码语言:javascript
复制
     var file : File = new File("file-path");
     webView.loadURL( file.url );
票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/15945088

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档