var imgX:Number = 2;//图片缩放大小
var imgY:Number = 2;//图片缩放大小
var moveTween:Tween;
var img_x:Number = img.scaleX;
var img_y:Number = img.scaleY;
import fl.transitions.easing.*;
import fl.transitions.Tween;
function onMouseWheelHandler(e:MouseEvent ):void {
if (e.delta>0) {
//上侦听
moveTween = new Tween(img, "scaleX", Elastic.easeOut, img_x, img.scaleX - imgX, 1, true);
moveTween = new Tween(img, "scaleY", Elastic.easeOut, img_y, img.scaleY - imgY, 1, true);
} else if (e.delta<0) {
//下侦听
moveTween = new Tween(img, "scaleX", Elastic.easeOut, img_x, img.scaleX + imgX, 1, true);
moveTween = new Tween(img, "scaleY", Elastic.easeOut, img_y, img.scaleY + imgY, 1, true);
}
}
stage.addEventListener(MouseEvent.MOUSE_WHEEL ,onMouseWheelHandler);
//拖拽
img.x = mouseX;
img.y = mouseY;
stage.addEventListener(MouseEvent.MOUSE_DOWN ,drag_);
stage.addEventListener(MouseEvent.MOUSE_UP ,drag_false);
function drag_(e:MouseEvent) {
img.startDrag();
}
function drag_false(e:MouseEvent) {
img.stopDrag();
}
img为场景实例名称。
var imgY:Number = 2;//图片缩放大小
var moveTween:Tween;
var img_x:Number = img.scaleX;
var img_y:Number = img.scaleY;
import fl.transitions.easing.*;
import fl.transitions.Tween;
function onMouseWheelHandler(e:MouseEvent ):void {
if (e.delta>0) {
//上侦听
moveTween = new Tween(img, "scaleX", Elastic.easeOut, img_x, img.scaleX - imgX, 1, true);
moveTween = new Tween(img, "scaleY", Elastic.easeOut, img_y, img.scaleY - imgY, 1, true);
} else if (e.delta<0) {
//下侦听
moveTween = new Tween(img, "scaleX", Elastic.easeOut, img_x, img.scaleX + imgX, 1, true);
moveTween = new Tween(img, "scaleY", Elastic.easeOut, img_y, img.scaleY + imgY, 1, true);
}
}
stage.addEventListener(MouseEvent.MOUSE_WHEEL ,onMouseWheelHandler);
//拖拽
img.x = mouseX;
img.y = mouseY;
stage.addEventListener(MouseEvent.MOUSE_DOWN ,drag_);
stage.addEventListener(MouseEvent.MOUSE_UP ,drag_false);
function drag_(e:MouseEvent) {
img.startDrag();
}
function drag_false(e:MouseEvent) {
img.stopDrag();
}
img为场景实例名称。