As3 基础学习 求教整理(1)

[ 2009-12-06 22:36:05 | 作者: Admin ]
: | |
简单XML数据条数获取--length()函数
var xmlUrl:String="xml文件.xml";
var urlrequest:URLRequest=new URLRequest(xmlUrl);
var loadxml:URLLoader=new URLLoader(urlrequest);
loadxml.addEventListener(Event.COMPLETE,xmlComplete);

function xmlComplete(e:Event):void
{
  var xml:XML=XML(e.target.data);//得到XML数据
  var HowMdata:int=xml.url.length();//得到xml数据条数
}

强制变量用法--this[]--不建议使用,应用Array
button01.addEventListener(MouseEvent.CLICK,Banner01);
button02.addEventListener(MouseEvent.CLICK,Banner02);
function Banner01(e:MouseEvent):void
{
}
function Banner02(e:MouseEvent):void
{
}

如上代码可由以下代码实现

for (var i:uint=1; i<3; i++) {
this["button0"+i].addEventListener(MouseEvent.CLICK,Banner);
}
function Banner(e:Event):void {
trace(e.target.name);
}

循环申请变量
var swfURLReq_01:URLRequest = new URLRequest(xmlSwfUrl[0]);
var swfURLReq_02:URLRequest = new URLRequest(xmlSwfUrl[1]);
var swfURLReq_03:URLRequest = new URLRequest(xmlSwfUrl[2]);
var swfURLReq_04:URLRequest = new URLRequest(xmlSwfUrl[3]);

如上代码可由以下代码实现

var re_array:Array =[];
for(var i=0;i<4;i++)
{
re_array.push (new URLRequest(xmlSwfUrl[i]));
}

AS3.0 的getoURL功能
navigateToURL(new URLRequest("http://www.baidu.com"));
[最后修改由 Admin, 于 2009-12-11 18:26:51]
评论Feed 评论Feed: http://localhost/lbs/feed.asp?q=comment&id=153
UTF-8 Encoding 引用链接: http://localhost/lbs/trackback.asp?id=153

这篇日志没有评论.

发表
表情图标
[smile] [confused] [cool] [cry]
[eek] [angry] [wink] [sweat]
[lol] [stun] [razz] [redface]
[rolleyes] [sad] [yes] [no]
[heart] [star] [music] [idea]
UBB代码
转换链接
表情图标
悄悄话
用户名:   密码:   注册?
验证码 * 请输入验证码