| 包 | flash.net |
| 类 | public dynamic class URLVariables |
| 继承 | URLVariables Object |
| 语言版本: | ActionScript 3.0 |
| 运行时版本: | AIR 1.0, Flash Player 9, Flash Lite 4 |
data 属性和 flash.net 包函数一起使用。
相关 API 元素
公共方法
| 方法 | 由以下参数定义 | ||
|---|---|---|---|
URLVariables(source:String = null)
创建一个新的 URLVariables 对象。 | URLVariables | ||
将变量字符串转换为指定 URLVariables 对象的属性。 | URLVariables | ||
![]() |
表示对象是否已经定义了指定的属性。 | Object | |
![]() |
表示 Object 类的实例是否在指定为参数的对象的原型链中。 | Object | |
![]() |
表示指定的属性是否存在、是否可枚举。 | Object | |
![]() |
设置循环操作动态属性的可用性。 | Object | |
![]() |
返回此对象的字符串表示形式,其格式设置遵守区域设置特定的约定。 | Object | |
以 MIME 内容编码格式 application/x-www-form-urlencoded 返回包含所有可枚举变量的字符串。 | URLVariables | ||
![]() |
返回指定对象的原始值。 | Object | |
构造函数详细信息
URLVariables | () | 构造函数 |
public function URLVariables(source:String = null)| 语言版本: | ActionScript 3.0 |
| 运行时版本: | AIR 1.0, Flash Player 9, Flash Lite 4 |
创建一个新的 URLVariables 对象。将 URLVariables 对象传递给 URLRequest 对象的 data 属性。
如果使用字符串来调用 URLVariables 构造函数,将自动调用 decode() 方法,以将该字符串转换成 URLVariables 对象的属性。
source:String (default = null) — 包含名称/值对的 URL 编码的字符串。
|
方法详细信息
decode | () | 方法 |
public function decode(source:String):void| 语言版本: | ActionScript 3.0 |
| 运行时版本: | AIR 1.0, Flash Player 9, Flash Lite 4 |
将变量字符串转换为指定 URLVariables 对象的属性。
该方法供 URLVariables 事件内部使用。绝大多数用户无需直接调用此方法。
参数
source:String — 包含名称/值对的 URL 编码的查询字符串。
|
引发
Error — 源参数必须是包含名称/值对的 URL 编码的查询字符串。
|
示例 ( 如何使用本示例 )
以下示例显示如何解析 URL 编码的字符串。ActionScriptExamples.com 提供的示例。
// The first method passes the string to be decoded to the URLVariables class constructor:
var urlVariables:URLVariables = new URLVariables("firstName=Tom&lastName=Jones");
lbl.text = urlVariables.lastName + "," + urlVariables.firstName;
// The second method uses the decode() method to parse the URL encoded string:
var urlVariables:URLVariables = new URLVariables();
urlVariables.decode("firstName=Tom&lastName=Jones");
lbl.text = urlVariables.lastName + "," + urlVariables.firstName;
toString | () | 方法 |
示例 如何使用本示例
URLVariablesExample.as
下例在一个新的浏览器窗口中打开位于 http://www.[yourDomain].com/application.jsp 上的远程应用程序,并将 URLVariables 对象中捕获的有关用户会话的数据传递给该应用程序。
该示例的要点遵循:
- 构造函数会创建名为
request的 URLRequest 实例,同时将远程应用程序的 URL 作为参数。 - 创建了一个 URLVariables 对象,并对它的两个属性进行了赋值。
- URLVariables 对象被赋给了 URLRequest 对象的
data属性。 - 该示例调用
navigateToURL,在一个新的浏览器窗口中打开远程应用程序的 URL。
注意:要运行该示例,必须将该示例中的远程应用程序 URL 替换为工作 URL。此外,需要用服务器代码处理 Flash Player 在 URLVariables 对象中捕获的信息。
package {
import flash.display.Sprite;
import flash.net.navigateToURL;
import flash.net.URLRequest;
import flash.net.URLVariables;
public class URLVariablesExample extends Sprite {
public function URLVariablesExample() {
var url:String = "http://www.[yourDomain].com/application.jsp";
var request:URLRequest = new URLRequest(url);
var variables:URLVariables = new URLVariables();
variables.exampleSessionId = new Date().getTime();
variables.exampleUserLabel = "guest";
request.data = variables;
navigateToURL(request);
}
}
}
Tue Jun 12 2018, 11:04 AM Z
隐藏继承的公共属性
显示继承的公共属性