【问题标题】:Adobe air mobile getPageContent and decode it using jsonAdobe air mobile getPageContent 并使用 json 解码
【发布时间】:2014-01-10 22:28:41
【问题描述】:

我正在尝试制作一个与我创建的网站进行通信的 Flash iPhone 应用程序,我应该以 JSON 格式获取信息...但我找不到允许我在空中执行此操作的函数。

有什么方法可以在 flash 中获取页面内容和解码 JSON?

【问题讨论】:

    标签: json actionscript-3 air file-get-contents


    【解决方案1】:

    获取页面内容

    GETgoogle.com 中的简单示例。

    var urlLoader:URLLoader = new URLLoader();
    var req:URLRequest = new URLRequest("http://google.com/");
    req.method = URLRequestMethod.GET;
    urlLoader.addEventListener(Event.COMPLETE, function( e:Event ):void
    {
        trace( e.currentTarget.data );
    });
    urlLoader.load( req );
    

    JSON 解码

    使用try...catch 来保证安全。

    try
    {
        JSON.parse(e.currentTarget.data);
    }catch( e:Error )
    {
        trace(e.message);
    }
    

    【讨论】:

      猜你喜欢
      • 2012-03-24
      • 1970-01-01
      • 1970-01-01
      • 2011-04-07
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2012-05-26
      • 1970-01-01
      相关资源
      最近更新 更多