点击浏览该文件 点击浏览该文件在这里我也做了个拖动滚动条使图片达到缓冲滚动效果.
以下是主要代码:
black.attachMovie("pic_1", "pic_1", 0);
var mask_height = 272;
var black_s_y = 64;
var k = .1;
black._y = black_s_y;
Var();
function Var() {
black_height = black._height;
//滚动画面的总长度
drag_hMax = mask_height-b_up._height*2-6;
drag._height = mask_height/black_height>=1 ? drag_hMax : mask_height*drag_hMax/black_height;
//这里的拖动条的长度根据图片来确定的,可以找不同长度的图片来试效果,其实假如图片比显示区域的高度小的话,拖动条也可以设置不可见
drag_s_y = black_s_y+b_up._height+3;
drag._y = drag_s_y;//处始拖动条的位置
drag_e_y = black_s_y+mask_height-b_up._height-3-drag._height;
}
black.onEnterFrame = function() {
this.pos_y = black_s_y-(drag._y-drag_s_y)*(black_height-mask_height)/(drag_e_y-drag_s_y);
//这里是拖动条和图片的一个比例关系
this._y += (this.pos_y-this._y)*k;
//图片位置的缓冲效果
};
drag.onPress = function() {
this.startDrag(false, this._x, drag_s_y, this._x, drag_e_y);
};
drag.onRelease = function() {
this.stopDrag();
};
//-------------up_down按钮----------
b_up.onPress = function() {
onEnterFrame = function () {
drag._y -= 5;
if (drag._y<=drag_s_y) {
drag._y = drag_s_y;
}
};
};
b_up.onRelease = function() {
onEnterFrame = null;
};
b_down.onPress = function() {
onEnterFrame = function () {
drag._y += 5;
if (drag._y>=drag_e_y) {
drag._y = drag_e_y;
}
};
};
b_down.onRelease = function() {
onEnterFrame = null;
};
//这里是上下按钮,按住不放,拖动会持续滚动
change_btn.onPress = function() {
!t ? (t=true, black.attachMovie("pic_2", "pic_2", 0)) : (t=false, black.attachMovie("pic_1", "pic_1", 0));
Var();
};
//虽然组件中有类似的功能,但是没有缓冲效果,本来想把这个写成个组件,但是没时间了(写组件好浪费时间).
//大家可以自行更改需要滚动的图片: )......
//进行了点修改,可以进行拖动,和任意拖动整个框架的位置,以及鼠标滑轮也能够起作用