本页面由 Flash 保存计划 从 Internet Archive 存档还原 · 快照 2006-07-08 · 原址 http://bbs.flash8.net/forums/1843487/ShowPost.aspx ← Flash 保存计划
欢迎光临 闪吧论坛 登录 | 注册 | FAQ | 搜索
Print Search
帖子排序:    
帖子发起人:comicfish   发起时间:2006-05-22 23:49 下午   回复:2
comicfish 离线,最后访问时间:2006-5-24 6:36:34 comicfish

等级:Flash1

等级:FLASH1
注册:2003-05-08
发贴:100
积分:17
2006-05-22, 23:49 下午   IP 地址:已记录  报告  收藏  楼主
FLASH类似网页数字跳转组件(好象是这么说明吧)-_-!

  • 今天在使用LIST组件的时候,发现当LIST项目超过千位左右时,FLASH资源消耗超级大,想到用分页的方式读取,但是如何制作一个类似网页数字跳页的组件呢?


    您所在的用户组无法下载或查看附件:222.gif。

    之前没做过,立即动手做做看!

    首先这个组件应当是完全动态生成的,包括按钮和数字

    其次要方便使用,可以设置显示多少个数字啊,颜色啊,高光颜色等等


    您所在的用户组无法下载或查看附件:111.gif。

    使用PageCount设置总页数,NowPage为初始化当前页数,PageStart从第几页开始显示

     

     


    附件:
    序号 附件名称 类型 文件大小 上传时间 下载次数
    1 分页组件.fla 未知格式 66Kb 2006-05-22 6
    2 111.gif 网络图片 1Kb 2006-05-22 18
    3 222.gif 网络图片 0Kb 2006-05-22 19
    4 分页组件.swf Flash动画 1Kb 2006-05-22 11

    承接各类FLASH程序开发,游戏开发
    MSN:comicfish2000@yahoo.com.cn
    comicfish 离线,最后访问时间:2006-5-24 6:36:34 comicfish

    等级:Flash1

    等级:FLASH1
    注册:2003-05-08
    发贴:100
    积分:17
    2006-05-23, 00:08 上午   IP 地址:已记录  报告  收藏  第2楼
    Re:FLASH类似网页数字跳转组件(好象是这么说明吧)-_-!

  • 代码不多,70行,其实可以更少的,想出来就做了,懒得去想了,达人就不要看了,遭笑话!

    给那些初学者讲解一下,希望各位可以从中发挥一下.

    var PageCount:Number=20;//这个值用来设置总的页数
    var NowPage:Number=1;//当前页数
    var PageStart:Number=1;//从第几页开始
    var ShowLimit:Number;//显示多少个数字
    var MoveSpeed:Number;//5454
    var fontColor;//文字颜色
    var HighLight;//高光颜色

    /*
    下面这几行代码初始化文字的基本颜色和字体
    */
    var my_fmt:TextFormat = new TextFormat();
    my_fmt.font = "宋体";
    my_fmt.color = fontColor;

    function DefaultColor(){
        my_fmt.color = fontColor;
        for(var i:Number=1;i<=PageCount;i++){
            this["tempMC"]["txt_"+i].setTextFormat(my_fmt);
        }
        my_fmt.color = HighLight;
        this["tempMC"]["txt_"+NowPage].setTextFormat(my_fmt);
    }

    //开始创建元件
    BuildStart();
    function BuildStart(){
          //首先创建一个空的MC,为了卸载和重写方便,我常把有可能需要重建或卸载的元件统一放置在一个MC中,这样在需要的时候,只需将此MC卸载即可
         this.createEmptyMovieClip("tempMC",1);
         //根据之前定义好的创建设置,生成元件并相应设置其坐标等
         for(var i:Number=1;i<=PageCount;i++){
            var TxtWidth:Number=i.toString().length*14;//文字筐的宽度,可能会有些不通用
            this["tempMC"].createTextField("txt_"+i,i,(i-1)*14,0,TxtWidth,20);
            this["tempMC"]["txt_"+i].text=i;
            this["tempMC"]["txt_"+i].selectable=false;
            DrawStick("tempMC","btn_"+i, [20,TxtWidth], 0x000000, 0, i*1001) ;//此函数为方便使用的绘制矩形,DrawStick(目标载体, 新元件名称, [高和宽], 颜色, 透明度, 深度)
            this["tempMC"]["btn_"+i]._x=(i-1)*14;
            this["tempMC"]["btn_"+i].data=i;//将数字信息载给按钮,方便使用.
            this["tempMC"]["btn_"+i].onRelease=function(){
                //当点击数字时需要触发的事件写在这里就可以
               NowPage=this.data;
               DefaultColor();
            }
     }
     

    //创建遮照用MC,与ShowLimit参数关联
     this.createEmptyMovieClip("maskMC",2);
     DrawStick("maskMC","mask", [20,ShowLimit*14], 0x000000, 100, 100000000);
     this["tempMC"].setMask(maskMC);
     

    //创建箭头,其实可以在一开始和文字一起创建,但是MASK时可能会麻烦点,没想太多,先这样吧
     this.createTextField("leftarrow",3,maskMC._x-28,0,28,20);
     this.createEmptyMovieClip("leftbtn",4);
     DrawStick("leftbtn","xxx", [20,18], 0x000000, 0, 1);
     this["leftbtn"]._x=maskMC._x-28;
     this["leftarrow"].text="<<";
     this["leftarrow"].setTextFormat(my_fmt);
     this["leftarrow"].selectable=false;
     
     this.createTextField("rightarrow",5,maskMC._width+10,0,28,20);
     this.createEmptyMovieClip("rightbtn",6);
     DrawStick("rightbtn","xxx", [20,18], 0x000000, 0, 1);
     this["rightbtn"]._x=maskMC._width+10;
     this["rightarrow"].text=">>";
     this["rightarrow"].setTextFormat(my_fmt);
     this["rightarrow"].selectable=false;
     
     this["leftbtn"].onPress=function(){
         if(this._parent["tempMC"]._x<0){
             this._parent["tempMC"]._x+=14;
         }
     }
     this["rightbtn"].onPress=function(){
         if(this._parent["tempMC"]._x>-this._parent["tempMC"]._width+this._parent["maskMC"]._width+18){
             this._parent["tempMC"]._x-=14;
         }
     }
     DefaultColor();
    }

     


    承接各类FLASH程序开发,游戏开发
    MSN:comicfish2000@yahoo.com.cn
    comicfish 离线,最后访问时间:2006-5-24 6:36:34 comicfish

    等级:Flash1

    等级:FLASH1
    注册:2003-05-08
    发贴:100
    积分:17
    2006-05-23, 00:15 上午   IP 地址:已记录  报告  收藏  第3楼
    Re:FLASH类似网页数字跳转组件(好象是这么说明吧)-_-!

  • //方便动态绘制矩形的代码
    function DrawStick(Target, CreatName, HandW, ColorRGB, Alpha, Depth) {
    this[Target].createEmptyMovieClip(CreatName, Depth);
    this[Target][CreatName].beginFill(ColorRGB, Alpha);
    this[Target][CreatName].lineStyle(0.2, 0xffffff, 0);
    this[Target][CreatName].moveTo(0, 0);
    this[Target][CreatName].lineTo(0, HandW[0]);
    this[Target][CreatName].lineTo(HandW[1], HandW[0]);
    this[Target][CreatName].lineTo(HandW[1], 0);
    this[Target][CreatName].lineTo(0, 0);
    this[Target][CreatName].endFill();
    }

    承接各类FLASH程序开发,游戏开发
    MSN:comicfish2000@yahoo.com.cn
    快速回复帖子

     




    标题: