我正在尝试在Action Script 2上创建缩放和平移选项。我想在舞台上而不是在动画片段上进行。我已经完成了基本编码,但我想创建拖动和缩放选项。任何帮助将不胜感激。
这是我的代码。我在舞台上有两个电影剪辑放大和缩小以放大和缩小舞台
zoom_mc.onPress = function() {
var zinxpos:Number;
var zinypos:Number;
zinxpos=zoom_mc._x;
zinypos=zoom_mc._y;
zoom_mc.onEnterFrame = function() {
Mouse.hide();
this._x = _root._xmouse;
this._y = _root._ymouse;
}
_root.onMouseDown = function() {
this._xscale+=10;
this._yscale+=10;
}
}
zoomout_mc.onPress = function() {
zoom_mc._x=zinxpos;
zoom_mc._y=zinypos;
zoomout_mc.onEnterFrame = function() {
Mouse.hide();
this._x = _root._xmouse;
this._y = _root._ymouse;
}
_root.onMouseDown = function() {
this._xscale-=10;
this._yscale-=10;
}
}
答案 0 :(得分:0)
这应该可以胜任。
var $stage = this;
var isDragging = false;
var mouseDownX = 0;
var mouseDownY = 0;
$stage.onEnterFrame = function() {
if(isDragging){
$stage._x += $stage._xmouse - mouseDownX;
$stage._y += $stage._ymouse - mouseDownY;
}
}
$stage.onMouseDown = function() {
isDragging = true;
mouseDownX = $stage._xmouse;
mouseDownY = $stage._ymouse;
}
$stage.onMouseUp = function() {
isDragging = false;
}
zoom_mc.onPress = function() {
$stage._xscale += 10;
$stage._yscale += 10;
}
zoomout_mc.onPress = function() {
$stage._xscale -= 10;
$stage._yscale -= 10;
}