1、在舞台上放入一图片,并将图片转换为原件, 取名small_pic
程序如下
import flash.events.MouseEvent;
var sx = small_pic.x;
var sy = small_pic.y;
small_pic.addEventListener("mouseOver", bigMC);
small_pic.addEventListener("mouseOut", smallMC);
function bigMC(me:MouseEvent){
me.target.x = sx-(small_pic.width/2);
me.target.y = sy-(small_pic.height/2);
me.target.scaleX = 2;
me.target.scaleY = 2;
me.target.play();
}
function smallMC(me:MouseEvent){
me.target.x = sx;
me.target.y = sy;
me.target.scaleX = 1;
me.target.scaleY = 1;
}
=====================================================
以点击图片的位置为中心点,进行放大缩小。 图片元件为image
import flash.display.MovieClip;
import flash.geom.Point;
import flash.events.MouseEvent;
image.addEventListener(MouseEvent.CLICK, clickHandler);
function clickHandler(event: MouseEvent): void {
var mc: MovieClip = event.currentTarget as MovieClip;
var point: Point = new Point(mc.mouseX, mc.mouseY);
scaleAtPoint(mc, point, mc.scaleX + 1);
}
function scaleAtPoint(target: MovieClip, point: Point, scale: Number): void {
var stagePoint: Point = target.localToGlobal(point);
target.scaleX = target.scaleY = scale;
var currentStagePoint: Point = target.localToGlobal(point);
target.x -= currentStagePoint.x - stagePoint.x;
target.y -= currentStagePoint.y - stagePoint.y;
}
联系客服