flash 鼠标拖动 影片剪辑前进和后退问题
flash鼠标拖动影片剪辑前进和后退我想让拖动反应区域在图片范围内但是不知道代码怎么打现在的代码是a1.stop();//鼠标数据。varstartMouseX=0;//...
flash 鼠标拖动 影片剪辑前进和后退 我想让拖动反应区域在图片范围内 但是不知道代码怎么打
现在的代码是
a1.stop();
// 鼠标数据。
var startMouseX = 0;
//var startMouseY = 0;
var lastMouseX = 0;
//var lastMouseY = 0;
// 是否正在按下状态。
var isDown = false;
// 一帧需移动10像素。
var onceFrameNeedMove = 10;
a11.onMouseDown = function() {
var mouseX = _root._xmouse;
//var mouseY = _root._ymouse;
startMouseX = mouseX;
//startMouseY = mouseY;
lastMouseX = mouseX;
//lastMouseY = mouseY;
isDown = true;
}
a11.onMouseMove = function() {
if(!isDown){return;}
var mouseX = _root._xmouse;
//var mouseY = _root._ymouse;
var moveX = mouseX - lastMouseX;
if(Math.abs(moveX) >= onceFrameNeedMove){
lastMouseX = mouseX;
if (moveX > 0)
{
_root.a1.nextFrame();
}
else
{
_root.a1.prevFrame();
}
}
}
a11.onMouseUp = function() {
isDown = false;
}
这个是SWF的地址
http://pan.baidu.com/s/1kUsp4uN
谁能帮我补充下代码或者更容易的代码 要AS2的 感谢 展开
现在的代码是
a1.stop();
// 鼠标数据。
var startMouseX = 0;
//var startMouseY = 0;
var lastMouseX = 0;
//var lastMouseY = 0;
// 是否正在按下状态。
var isDown = false;
// 一帧需移动10像素。
var onceFrameNeedMove = 10;
a11.onMouseDown = function() {
var mouseX = _root._xmouse;
//var mouseY = _root._ymouse;
startMouseX = mouseX;
//startMouseY = mouseY;
lastMouseX = mouseX;
//lastMouseY = mouseY;
isDown = true;
}
a11.onMouseMove = function() {
if(!isDown){return;}
var mouseX = _root._xmouse;
//var mouseY = _root._ymouse;
var moveX = mouseX - lastMouseX;
if(Math.abs(moveX) >= onceFrameNeedMove){
lastMouseX = mouseX;
if (moveX > 0)
{
_root.a1.nextFrame();
}
else
{
_root.a1.prevFrame();
}
}
}
a11.onMouseUp = function() {
isDown = false;
}
这个是SWF的地址
http://pan.baidu.com/s/1kUsp4uN
谁能帮我补充下代码或者更容易的代码 要AS2的 感谢 展开
展开全部
写了一个元件绑定类,绑定到影片剪辑上就具有拖动跳帧功能了
/**
* 伪3D拖拽MC绑定类
* @author 秋色烽火
*/
class com.set2get.as2.view.McDragPlay extends MovieClip
{
private var _mouseX:Number = 0;
private var _mouseY:Number = 0;
private var _baseFrame:Number = 0;
/** 每帧对应的坐标差距 */
private var _dragLength:Number = 15;
/** 主场景引用 */
private var _Root:MovieClip;
/** debug输出控制 */
private var _isDebug:Boolean = false;
private var _debugText:TextField;
public function McDragPlay()
{
super();
init();
}
private function init():Void {
onPress = onDown_func;
onRelease = onReleaseOutside = onUp_func;
}
private function initDebug():Void {
_debugText = this.createTextField("tDebug", this.getNextHighestDepth(), 0, 0, 1, 1);
_debugText._x = 30;
_debugText._y = 60;
_debugText.autoSize = "left";
}
private function onUp_func():Void
{
delete this.onMouseMove;
}
private function onDown_func():Void
{
_mouseX = int(_Root._xmouse);
_mouseY = int(_Root._ymouse);
_baseFrame = _currentframe;
onMouseMove = onMouseMove_func
}
private function onMouseMove_func():Void
{
var _diff:Number = _Root._xmouse - _mouseX; //计算坐标差
var _tFrame:Number = int(_diff / _dragLength); //计算偏移帧数 正或负
var _tEndFrame:Number = (_totalframes + ((_baseFrame + _tFrame) % _totalframes)) % _totalframes + 1;
//基准帧+偏移量+总帧数 取模总帧数,修正加1,就是目标帧数
this.gotoAndStop(_tEndFrame);
if (_isDebug) {
_debugText.text = _tEndFrame + "";
}
}
/** debug set */
public function set isDebug(value:Boolean):Void
{
_isDebug = value;
if (value && !_debugText) initDebug();
}
/** 鼠标移动偏移量 对应移动帧快慢 默认值为15*/
public function set dragLength(value:Number):Void
{
if (value < 1) return;
_dragLength = value;
}
public function set root(value:MovieClip):Void {
_Root = value;
}
}
追问
我可以在问一下吗 如果我要做到到了最后一帧就不能继续播放只能后退 应该怎么做?
追答
里面的McDragPlay.as替换成这个
其实也就是代码段更改一下
var _tEndFrame:Number = _baseFrame + _tFrame;
if (_tEndFrame < 1) _tEndFrame = 1;
if (_tEndFrame > _totalframes) _tEndFrame = _totalframes;
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询