天才教育網(wǎng)合作機構 > 培訓機構 >

                                                                                        東莞設計培訓網(wǎng)

                                                                                        歡迎您!
                                                                                        朋友圈

                                                                                        全國統一學(xué)習專(zhuān)線(xiàn) 9:00-21:00

                                                                                        位置:培訓資訊 > flash 和asp 分頁(yè)的一點(diǎn)心得

                                                                                        flash 和asp 分頁(yè)的一點(diǎn)心得

                                                                                        日期:2005-12-23 00:00:00     瀏覽:418    來(lái)源:東莞設計培訓網(wǎng)
                                                                                        最近無(wú)聊,做了一個(gè)自己bog的FLASH界面,用的blog是破廢墟的版本.
                                                                                        看了這個(gè)的一些帖子,學(xué)到了很多東西,現在和大家一起分享
                                                                                        flash現在只是一個(gè)顯示的功能,過(guò)程中看了一些別人的東西,覺(jué)得分頁(yè)似乎有很簡(jiǎn)單的實(shí)現方式.
                                                                                        效果可以看我的:
                                                                                        基本上都是用xml傳送的.
                                                                                        顯示用 list 組件和 datagrid 都可以,這里我用的是動(dòng)態(tài)文本,因為覺(jué)得組件用的太麻煩了.
                                                                                        所以用了蠢辦法,沒(méi)辦法,找不到更好的~~~
                                                                                        下面代碼中的 list[..]就是動(dòng)態(tài)文本的名趁,一次顯示15條
                                                                                        //顯示程序如下:
                                                                                        //楨名稱(chēng) "list"
                                                                                        stop();
                                                                                        var logList = new XML();
                                                                                        var logroot;
                                                                                        var //當前頁(yè)
                                                                                        var T //保存總頁(yè)
                                                                                        var //總日志數
                                                                                        var //日志分類(lèi)名稱(chēng)
                                                                                        var temp;
                                                                                        var i:Number;

                                                                                        //這里我用一個(gè)數組儲存了對應的id號,如果用組件就不用這么麻煩了
                                                                                        var ids = new Array(15);

                                                                                        //兩個(gè)按鈕,用來(lái)翻頁(yè)
                                                                                        bn_u.enabled = false;
                                                                                        bn_d.enabled = false;
                                                                                        if (page == null or page<1) {
                                                                                        page = 1;
                                                                                        }
                                                                                        //------------------------------
                                                                                        //清除函數;
                                                                                        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 = "正在讀取數據...";
                                                                                        logList.ignoreWhite = true;
                                                                                        logList.load("Tree_list.asp?log_cat="+cat_id+"&page="+page);
                                                                                        //------------------------------------------------
                                                                                        //get數據函數
                                                                                        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;
                                                                                        //循環(huán)讀取節點(diǎn)
                                                                                        while (temp.nextSibling != null) {
                                                                                        temp = temp.nextSibling;
                                                                                        i++;
                                                                                        //如果是用別的方式顯示,只需要改一下就可以了
                                                                                        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+"共有日志"+Tnum+"篇 共"+Tpage+"頁(yè) 當前是第"+page+"頁(yè) "+"15/頁(yè)";
                                                                                        bn_u.enabled = true;
                                                                                        bn_d.enabled = true;
                                                                                        } else {
                                                                                        pageInfo.text = "當前沒(méi)有日志。";
                                                                                        list.ltitle1.text = "讀取數據出錯,請聯(lián)系管理員!";
                                                                                        }
                                                                                        }

                                                                                        //一個(gè)自定義的格式標題的函數,怕標題太長(cháng)
                                                                                        function Ftitle(s, n) {
                                                                                        if (length(s)>n) {
                                                                                        s = s.substring(0, n-1)+"...";
                                                                                        }
                                                                                        return s;
                                                                                        }
                                                                                        logList.onLoad = logFunc;
                                                                                        //-------------------------------------
                                                                                        //按鈕動(dòng)作
                                                                                        Bn_up = new Object();
                                                                                        //按鈕事件,判斷頁(yè)面大小是否超過(guò)值
                                                                                        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_root.page++;
                                                                                        gotoAndPlay("cycle");
                                                                                        } else {
                                                                                        stop();
                                                                                        }
                                                                                        };
                                                                                        bn_u.addEventListener("click", Bn_up);
                                                                                        bn_d.addEventListener("click", Bn_d);

                                                                                        楨"cycle"只有一個(gè)話(huà):
                                                                                        gotoAndPlay("list");
                                                                                        //形成一個(gè)簡(jiǎn)單的循環(huán)

                                                                                        Tree_list.asp:
                                                                                        //log 是我的日志表 ,log_cat是分類(lèi)表
                                                                                        下面的asp很清楚了


                                                                                        <%
                                                                                        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="[全部分類(lèi)]"
                                                                                        else
                                                                                        log_name="["&rs("cat_name")&"]"
                                                                                        End if
                                                                                        ’以下輸出xml
                                                                                        ’------------------------------------------------
                                                                                        response.write("")
                                                                                        if rs.eof then
                                                                                        rs.close
                                                                                        else
                                                                                        do while not rs.eof and pageSize>0
                                                                                        response.write("")
                                                                                        response.write("
                                                                                        ")
                                                                                        pageSize=pageSize-1
                                                                                        rs.movenext
                                                                                        loop
                                                                                        rs.close
                                                                                        End if
                                                                                        //關(guān)閉rs
                                                                                        call Tree_rsclose
                                                                                        call Tree_conclose
                                                                                        response.write("
                                                                                        ")
                                                                                        %>
                                                                                        代碼好象很亂,希望能對正在做這個(gè)的朋友有點(diǎn)幫助,如果以上有bug,請指教
                                                                                        如果本頁(yè)不是您要找的課程,您也可以百度查找一下:

                                                                                        奇米在线7777在线精品|国产成人精品免费视|精品无码不卡一区二区三区|国内综合精品午夜久久资源|亚洲视频在线观看..