如何从 Flash AS3 中的 URL 获取/获取变量 [英] How to get/obtain Variables from URL in Flash AS3

查看:27
本文介绍了如何从 Flash AS3 中的 URL 获取/获取变量的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

所以我有一个 URL,我需要我的 Flash 电影从中提取变量:

So I have a URL that I need my Flash movie to extract variables from:

示例链接:
http://www.example.com/example_xml.php?aID=1234&bID=5678

我需要获取 aID 和 bID 号码.

I need to get the aID and the bID numbers.

我可以通过 ExternalInterface 将完整的 URL 转换为字符串

I'm able to get the full URL into a String via ExternalInterface

var url:String = ExternalInterface.call("window.location.href.toString");
if (url) testField.text = url;

只是不确定如何操作字符串以获取 1234 和 5678 数字.

Just unsure as how to manipulate the String to just get the 1234 and 5678 numbers.

感谢任何提示、链接或帮助!

Appreciate any tips, links or help with this!

推荐答案

创建 URLVariables 的新实例.

// given search: aID=1234&bID=5678
var search:String = ExternalInterface.call("window.location.search");
var vars:URLVariables = new URLVariables(search);
trace(vars.aID); // 1234
trace(vars.bID); // 5678

这篇关于如何从 Flash AS3 中的 URL 获取/获取变量的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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