hk_mc是滑块,jdt_mc是进度条,yp_mc是影片。
在添加影片的相应帧上添加以下代码:
var td:Boolean = true;
hk_mc.onPress = function() {
td = false;
startDrag(this, false, jdt_mc._x, jdt_mc._y-hk_mc._height/2, jdt_mc._x+jdt_mc._width-hk_mc._width, jdt_mc._y-hk_mc._height/2);
};
//按下滑块时开始拖动滑块。
hk_mc.onRelease = function() {
yp_mc.gotoAndPlay(int(yp_mc._totalframes*(hk_mc._x-jdt_mc._x)/(jdt_mc._width-hk_mc._width)));
td = true;
stopDrag();
};
//释放滑块时停止拖动。
如果是停止拖动时想让影片不自动播放,则把上面的gotoAndPlay换成gotoAndStop。
hk_mc.onReleaseOutside = function() {
td = true;
stopDrag();
};
//鼠标位于滑块外部时,停止拖动。
onEnterFrame = function () {
if (td) {
hk_mc._x = jdt_mc._x+(jdt_mc._width-hk_mc._width)* yp_mc._currentframe/sxmx._totalframes;
} else {
yp_mc.gotoAndPlay(int(yp_mc._totalframes*(hk_mc._x-jdt_mc._x)/(jdt_mc._width-hk_mc._width)));
}
};
|