看看dragRoll与rollPage是如何搭档【ThumbRoll类】
即时获得麻球游戏开发的最新消息,关注游戏开发者热门讨论,请各位开发者申请加入麻球官方群:121304476
也可以follow catfly围脖:t.sina.com.cn/iscat

关于这两个类前面已经有很详细的文章了。

那么它是如何搭档的呢?我写了这个ThumbRoll类,看看示例吧。

This movie requires Flash Player 9

使用方法:


var thumbRoll:ThumbRoll;

//create thumbRoll
var thumbvars:Object={childMargin:10,childPad:8,childWidth:120,childHeight:90,pageNum:4};
thumbRoll=new ThumbRoll(albumData["imgUrlArr"],ThumbDrag,ThumbUI,thumbvars,"x");
thumbRoll.addEventListener("gotoImage",gotoImage);
addChild(thumbRoll);
thumbRoll.dragY=100;
thumbRoll.dragX=0;

function gotoImage(e:Event):void {
	trace(thumbRoll.current);
}

这个类的参数说明:ThumbRoll(_thumbArr:Array,_dragUi:Class,_thumbUi:Class,$vars:Object,$aix:String=”x”)

_thumbArr:Array 所有图片的地址的数组
_dragUi:Class 拖动按钮的绑定类

_thumbUi:Class 缩略图的背景UI绑定类

$vars:Object 这个对象会接收五个参数,可以设置以下属性

pageNum: 每页子对象数
childWidth: 子对象宽
childHeight: 子对象高
childPad: 子对象内边距
childMargin: 子对象外边距

$aix:String 水平或是垂直方向,”x”为水平,”y”为垂直。

dragX 属性 可以设置拖动条的水平位置

dragY 属性 可以设置拖动条的垂直位置

nextPage()方法 翻到下一页

prePage()方法 翻到上一页

hideDrag()方法 如果不需要拖动条,可以用此方法隐藏

pickPosition(n:Number)方法 可以通过点击拖动横条获取鼠标的位置来定位拖动杆

updateThumb(n:Number)方法 可以从外部更新当前缩略图为第几张

autoRollPage()方法 当前缩略图到达新的分页时可以从外部驱动翻页

有兴趣的朋友可以下载原文件看看。

猫抓鱼