Flash and ASP paging a little experience and Flash script _ Application Tips
Source: Internet
Author: User
Read this some of the posts, learned a lot of things, and now share with you
Flash is now just a display function, the process of seeing some other people's things, feel that pagination seems to have a very simple way of implementation. Basically, it's all in XML. Display with the list component and the DataGrid, and here I use dynamic text, Because I think the components used too much trouble. So with a stupid way, no way, can not find a better ~ ~ ~ ~ ~ The following code in the list[...] is the name of the dynamic text, which displays 15 at a time.
The display program is as follows:
Hardwood name "List"
Stop ();
var loglist = new XML ();
var logroot;
var Page:number; Current page
var Tpage:number; Save Total Page
var Tnum:number; Total log Count
var logname:string; Journal category name
var temp;
var I:number;
Here I use an array to store the corresponding ID number, if the component is not so cumbersome
var ids = new Array (15);
Two buttons for paging
bn_u.enabled = false;
bn_d.enabled = false;
if (page = = NULL or page<1) {
page = 1;
}
//------------------------------
Clear function;
function Myclear () {
For (I=1 i<16; i++) {
Ids[i-1] = 0;
list["LBN" +i]._visible = false;
list["Ltitle" +i].text = "";
list["Lauthor" +i] = "";
list["Ltime" +i] = "";
}
}
//--------------------------------------
//--------------------------------------
Myclear ();
Pageinfo.text = "reading data ...";
Loglist.ignorewhite = true;
Loglist.load ("tree_list.asp?log_cat=" +cat_id+ "&page=" +page);
//------------------------------------------------
Get Data function
function Logfunc (e) {
if (e) {
Logroot = Loglist.firstchild;
LogName = Logroot.attributes.logname;
Tpage = Logroot.attributes.Tpage;
Tnum = Logroot.attributes.Tnum;
temp = Logroot.firstchild;
List.ltitle1.text = Ftitle (Temp.firstChild.nodeValue, 22);
List.lauthor1 = Temp.attributes.author;
list.ltime1 = Temp.attributes.Addtime;
Ids[0] = temp.attributes.id;
i = 1;
List.lbn1._visible = true;
Loop Read node
while (temp.nextsibling!= null) {
temp = temp.nextsibling;
i++;
If it is shown in a different way, just change it.
Ids[i-1] = temp.attributes.id;
list["LBN" +i]._visible = true;
list["Ltitle" +i].text = Ftitle (Temp.firstChild.nodeValue, 22);
list["Lauthor" +i] = Temp.attributes.author;
list["Ltime" +i] = temp.attributes.Addtime;
}
Pageinfo.text = logname+ "Total log" +tnum+ "a total of" +tpage+ "page is currently the first" +page+ "page" + 15/page ";
Bn_u.enabled = true;
Bn_d.enabled = true;
} else {
Pageinfo.text = "There is currently no log. ";
List.ltitle1.text = "Error reading data, please contact admin!" ";
}
}
A custom format title function that's afraid the title is too long
function Ftitle (s, N) {
if (length (s) >n) {
s = s.substring (0, n-1) + "...";
}
return s;
}
Loglist.onload = Logfunc;
//-------------------------------------
Button action
bn_up = new Object ();
Button event to determine whether the page size exceeds the value
Bn_up.click = function (evt) {
if (page>1) {
_root.page--;
gotoAndPlay ("cycle");
} else {
Stop ();
}
};
Bn_d = new Object ();
Bn_d.click = function (evt) {
if (page<tpage) {
_root.page++;
gotoAndPlay ("cycle");
} else {
Stop ();
}
};
Bn_u.addeventlistener ("click", Bn_up);
Bn_d.addeventlistener ("click", Bn_d);
Frame "cycle" only one word:
gotoAndPlay ("list");
To form a simple loop
Tree_list.asp:
Log is my logging table, Log_cat is the category table
The following ASP is very clear
<?xml version= "1.0" encoding= "gb2312"?>
<%
Response.ContentType = "Text/xml"
Response.CacheControl = "No-cache"
Response.AddHeader "Pragma", "No-cache"
Response.Expires = 0
Dim log_cat,page,pagesize,tnum,tpage,log_name
Page=treerequest ("page", 1)
Log_cat=treerequest ("Log_cat", 1)
Pagesize=15
Call Tree_rs
If log_cat=0 or log_cat= "" Then
Sql= "SELECT * from Log order by Written_time desc,log_id DESC"
Else
Sql= ' select * from Log,log_cat where log.cat_id=log_cat.id and cat_id= ' &log_cat& ' ORDER by Written_time Desc,log_ ID DESC "
End If
Rs.Open sql,conn,1,1
Rs. Pagesize=pagesize
Tnum=rs. RecordCount
Tpage=int (tnum/pagesize*-1) *-1
If page= "" then page=1
If Tnum<>0 then Rs. Absolutepage=page
If log_cat=0 or log_cat= "" Then
Log_name= "[All Categories]"
Else
Log_name= "[" &rs ("Cat_name") & "]"
End If
' The following output XML
'------------------------------------------------
Response.Write ("<tree logname= '" &log_name& "' tnum= '" &Tnum& "' tpage= '" &Tpage& "' >")
If Rs.eof Then
Rs.close
Else
Do, not rs.eof and pagesize>0
Response.Write ("<trees author=" &rs ("Log_author") & "' Addtime= '" &rs ("Written_time") & "' Id= '" &rs ("log_id") & "' >")
Response.Write ("<![ cdata["&rs (" Log_tittle ") &"]]></trees> ")
Pagesize=pagesize-1
Rs.movenext
Loop
Rs.close
End If
Turn off RS
Call Tree_rsclose
Call Tree_conclose
Response.Write ("</Tree>")
%>
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.
A Free Trial That Lets You Build Big!
Start building with 50+ products and up to 12 months usage for Elastic Compute Service