的StageWebView,iOS系统中,本地文件 [英] StageWebView, iOS, local files

查看:167
本文介绍了的StageWebView,iOS系统中,本地文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我建立了使用Flash Builder,则Flex 4.6和AIR 3.5 IOS移动应用程序。我调查使用的StageWebView呈现一些HTML5的内容。

I'm building a mobile app for IOS using Flash Builder, Flex 4.6 and AIR 3.5. I'm investigating using StageWebView to render some HTML5 content.

我想要做的就是建立内容到应用程序,而不是把它的服务器上。它是相对静态的。但我阅读(确认),在应用程序内的文件不能直接通过的StageWebView使用。但是,下面的一个建议,我有应用程序中的内容复制到一个临时文件夹,然后创建一个文件://网址的StageWebView,这似乎工作:

What I want to do is to build the content into the app, as opposed to putting it on a server. It's relatively static. But I read (and confirmed) that in-app files can't be used directly by StageWebView. But following a suggestion, I'm have the app copy the content to a temp folder, then create a file:// URL for StageWebView, which seems to work:

//  create the view
var webView:StageWebView = new StageWebView();
webView.stage = this.stage;
webView.viewPort = new Rectangle( 0, 0, stage.stageWidth, stage.stageHeight);

//  copy the HTML5 content to a temp directory
var src:File = File.applicationDirectory.resolvePath("myFolder");
var temp:File = File.createTempDirectory().resolvePath("myFolder");
copyFolderContentsToAnotherFolder(src,temp);

//  what's the URL
var newPath:String = "file://" + temp.nativePath + "/index.html";

//  load it
webView.loadURL(newPath);

这是一个坏主意?将临时文件堆积在我的设备没有办法删除它们?

Is this a bad idea? Will temporary files pile up in my device with no way to delete them?

我也想过具有由端口上监听并提供数据的请求的文件,因为他们来的应用程序实现的最小的HTTP服务器。这将使我们能够为他们的在应用程序的位置的文件的StageWebView,没有复制。为此,我们在桌面AIR应用程序,它工作得很好。但是,这种方法使用ServerSocket的,我发现,不支持移动。是否有其他办法做到这一点?

I also thought of having the app implement an minimal HTTP server by listening on a port and supplying the data for requested files as they come. This would allow us to serve the files to StageWebView from their in-app locations, without copying. We do this in a desktop air app and it works very nicely. But, that approach uses ServerSocket, which I discover is not supported on mobile. Is there an alternative way to do this?

最后的StageWebView不会在Flash Builder中的iOS模拟器运行良好,使得调试困难。它是最好还是去把FB 4.7,它(应该)允许我用它使用X code的iOS模拟器?

Finally, StageWebView does not work well in the Flash Builder iOS simulator, making debugging difficult. Is it best to just go and get FB 4.7, which (should) allow me to use it with XCode's iOS simulator?

感谢

推荐答案

嗯,看来我可以直接解决在应用程序的内容,我只需要构造一个文件:// URL吧:

Well, it seems I CAN directly address the in-app content, I just have to construct a file:// URL for it:

var src:File = File.applicationDirectory.resolvePath("myFolder/index.html");
var newPath:String = "file://" + src.nativePath;
webView.loadURL(newPath);

这篇关于的StageWebView,iOS系统中,本地文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆