|
ASP与Flash8联合打造简单新闻评论系统(2) var xml = new XML(); //创建XML类 xml.load("pl_list.asp"); //加载外部文件 msg = "正在加载评论……"; xml.onLoad = function(ok) { if (ok) { init(); //加载成功后调用init函数 } }; //解析外部文件 function init() { _root.attachMovie("pllist", "pllist", 1); //为主场景添加一个pllist影片剪辑 _root.pllist.tot = "共"+xml.firstChild.attributes.tot+"条"+" 当前第"+xml.firstChild.attributes.curpage+"页";//获得所有评论数与当前页码 for (i=0; i drawPllist(i);//绘制评论列表 } _root.pagecount(xml.firstChild.attributes.tot); msg = "加载成功"; } //评论列表绘制函数 function drawPllist(c) { _root.pllist.attachMovie("pl", "pl"+c, c);//将库中影片剪辑附加到pllist影片剪辑中 with (_root.pllist["pl"+c]) {//这句可以用with(eval("_root.pllist.pl"+c)){替换 _x = 20; //设置厅距离 _y = 20+c*100;//设置上距离 user = xml.firstChild.childNodes[c].childNodes[0];//获得呢称 dateandtime = xml.firstChild.childNodes[c].childNodes[1].toString();//获得评论时间 contents = xml.firstChild.childNodes[c].childNodes[2].toString();//获得评论内容 } var xid = xml.firstChild.childNodes[c].childNodes[3].toString();//获得评论id,用于删除操作 _root.pllist["pl"+c].del.onRelease = function() { xml.load("pl_del.asp?id="+substring(xid, 5, length(xid)-9)); xml.onLoad = function(ok) { if (ok) { msg = "删除成功!"; } xml.load("pl_list.asp");//删除后再次加载 xml.onLoad = function(ok) { if (ok) { init(); } }; }; }; } //翻页处理 function pagecount(tot) { if (tot%5 == 0) { //计算页数 pages = int(tot/5); } else { pages = int(tot/5)+1; } for (var j = 1; j<=pages; j++) { drawpage(j); } } //绘制翻页按钮 function drawpage(j) { _root.pllist.attachMovie("gopage", "gopage"+j, j+10); with (_root.pllist["gopage"+j]) { _x = 100+j*30; _y = 520; curpage = j; } _root.pllist["gopage"+j].onRelease = function() { xml.load("pl_list.asp?page="+j); msg = "正在加载评论……"; xml.onLoad = function(ok) {
|