2013-05-17 85 views

回答

0

您可以使用File Class加载本地HTML文件。所以它会是这样的:

var _locaWebFile:File = File.documentsDirectory.resolvePath(pathToHTMLContent);  
var _webview:StageWebView = new StageWebView(); 
_stage.scaleMode = StageScaleMode.NO_SCALE; 
_webview.stage = _stage; 
_webview.loadURL(_localWebFile.url); 
_webview.addEventListener(flash.events.Event.COMPLETE, loadData); 

function loadData(e:Event):void 
{ 
    _webview.viewPort = new Rectangle(0, 0, _stage.stageWidth, _stage.stageHeight); 
} 

此外,您可能必须确保您的图像路径是正确的。

0

解决方案涉及将所有必要的文件(html,images,css)复制到存储目录,然后在那里调用您的html。图像和CSS的URL将相对于该目录。

此代码显示如何将名为html的整个目录的内容复制到该存储目录中,然后将test.html加载到StageWebView对象中。

 var source:File = File.applicationDirectory.resolvePath("html/") ; 
     var destination:File = File.applicationStorageDirectory; 
     source.copyTo(destination, true); 
     var initialURL = new File(destination.resolvePath("test.html").nativePath).url; 
     webView.loadURL(initialURL); 

请注意,您将负责清理该目录。

+0

我使用这种方法在我的android测试设备上取得了巨大的成功(虽然需要解决有效的'清理'问题),但无法让方法在iOS上工作。空气应用程序(特别是应用程序中的stagewebview)根本不加载html,并且不会产生任何错误。是文件:/ /在iOS上的作品?似乎它应该只是工作相同,因为它内部的空气,但我猜ios文件系统可以工作不同?这种方法在ios上的任何经验? – tamak

相关问题