ios - Flash Air iOS 开发 : Is it possible to launch a browser from within your applications?

标签 ios flash browser air

我使用 Flash Air 开发 iOS 游戏。能够从您的应用程序中启动浏览器会很好。任何想法将不胜感激!!

最佳答案

您可以使用 StageWebView在您的 AIR 应用程序中打开网页。

这是在屏幕右半边(又名舞台)打开页面的示例用法:

private var _web_view:StageWebView;
private function init_stagewebview(url:String):void 
{
  if (_web_view) {
    throw new Error('init_stagewebview() called with existing _web_view - you must call cleanup first');
  }
  _web_view = new StageWebView();
  var stage:Stage = NativeApplication.nativeApplication.activeWindow.stage;
  _web_view.stage = stage;
  _web_view.viewPort = new Rectangle(stage.stageWidth/2,0,stage.stageWidth/2, stage.stageHeight);
  _web_view.addEventListener(ErrorEvent.ERROR, handle_error);
  _web_view.addEventListener(IOErrorEvent.IO_ERROR, handle_error);
  _web_view.addEventListener(SecurityErrorEvent.SECURITY_ERROR, handle_error); 
  _web_view.addEventListener(LocationChangeEvent.LOCATION_CHANGING, handle_loc_change);
  _web_view.loadURL(url);
}

private function handle_loc_change(e:LocationChangeEvent=null):void 
{ 
  if (e) {
    var loc:String = e.location;
    trace(" -- webView location changed to: "+loc);

    // Disable the navigation if you want to (this is a common
    // way of passing data from web to AIR):
    // e.preventDefault();
  }
}

private function cleanup_web_view():void 
{
  if (_web_view == null) return;
  _web_view.removeEventListener(ErrorEvent.ERROR, handle_error);
  _web_view.removeEventListener(IOErrorEvent.IO_ERROR, handle_error);
  _web_view.removeEventListener(SecurityErrorEvent.SECURITY_ERROR, handle_error);
  _web_view.removeEventListener(LocationChangeEvent.LOCATION_CHANGING, handle_loc_change);
  _web_view.viewPort = null;
  _web_view.dispose();
  _web_view = null;
}

private function handle_error(e:ErrorEvent):void 
{ 
  if (e) trace("- - - - webView Error:" + e.toString());
}

关于ios - Flash Air iOS 开发 : Is it possible to launch a browser from within your applications?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9272789/

相关文章:

javascript - 将 HTML5 元素与 XHTML 文档类型结合使用

java - 像在 Eclipse 中一样,用于 Netbeans 的内置 Web 浏览器

android - 如何在 Flutter 中使 Expanded 中的文本可滚动

javascript - 在准确的时间停止视频

flash - 如何反编译 swf 文件

c# - OneDrive oauth wpf 禁用自动登录浏览器

ios - 所有动画执行缓慢

objective-c - NSNetService 的 TXTRecordData 解析后为零

ios - 我的类别 NSDate+Api 现在不适用于 Swift 中的 Date 类(迁移到 Swift 3 和 Swift 互操作性之后)

iphone - as3 air for ios 获取屏幕设备分辨率