1、读取urlLoader中的多个变量例子
//要读取的变量:someText=text&someNumber=3 var loader:URLLoader = URLLoader( event.target ); // Use a for . . . in loop to loop over all of the variables that // were loaded for ( var property:String in loader.data ) { // property 就是data里的变量名 trace( property + " = " + loader.data[property] ); }
=========================================================================
2、loader的DataFormat
//设置
loader.dataFormat = DataFormat.**;
data 属性的数据类型是根据dataFormat 属性的设置而决定的,如果设置为DataFormat.TEXT,则data 属性的值为String 类型,如果设置DataFormat.VARIABLES,则是Object 类型(即UTF-编码),如果设置为DataFormat.BINARY,则data 的数据类型为flash.util.ByteArray
=========================================================================
3、XML赋值
一、XML对象
var example:XML = <abc><a>eh</a><b>bee</b><c>see</c></abc>;
****************************
二、XML对象,使用XML文本为变量
var username:String = "Darron";
var score:int = 1000;
var example:XML =
<gamescore>
<username>{username}</username>
<score>{score}</score>
</gamescore>;
****************************
三、字符串
var str:String = "<gamescore><username>" + username + "</username>"
+ "<score>" + score + "</score></gamescore>";
var example:XML = new XML( str );
=========================================================================
4、添加XML节点
var example:XML = <example />;
example.emptyElement = "";
或
var example:XML = <example />;
var id:int = 10;
example[ "user" + id ] = "";
或
var example:XML = <example/>;
example.two = "";
example = example.insertChildBefore( example.two, <one /> );
example = example.insertChildAfter( example.two, <three /> );
=======================================================================
5、Loader的XML不符合XML数据时的错误判断:
TypeError 异常就是不能成功转换为XML 实例时抛出的
catch ( e:TypeError ) {
trace( "Could not parse text into XML" );
trace( e.message );
}
=======================================================================
6、XML中含有特殊字符,使用CDATA
<example><![CDATA[a < b]]></example>
<htmlExample><![CDATA[<a href="http://www.darronschall.com">Darron</a>]]></htmlExample>
当XML 被解析时,CDATA 标签中的内容原封不动。
========================================================================