Flash教程:简单制作图形变换效果
来源:岁月联盟
时间:2007-10-05
图1

按Ctrl+F8新建一个景片剪辑
图2

图3

新建图层2,把图把2拖到图层1下边,然后在图层2第1帧用矩形工具画一个863*122的矩形,填充上渐变色
图4

图5

然后在1到50帧间任意一帧创建形状补间动画
图6

图7

下面,回到场景中,按Ctrl+L打开库,从中把刚做好的影片剪辑拖到场景中,然后点下场景中的影片剪辑,按F9打开动作面板,输入下面的代码
onClipEvent (mouseMove) { //mouseMove指鼠标移动
x = _root._xmouse; //返回鼠标的X坐标值
y = _root._ymouse; //返回鼠标的Y坐标值
if (x>=this._x) {
rot = Math.atan((y-this._y)/(x-this._x))*180/Math.PI;
} else {
rot = Math.atan((y-this._y)/(x-this._x))*180/Math.PI+180;
}
//Math.atan是用来计算正切值 //Math.PI表示圆周率 //计算得出,rot的值是一个角度值,也就是鼠标移动前那个点和鼠标移动后那条线的角度!最终实现的效果就是场景中的影片的角度方向跟随鼠标的方向移动
setProperty("", _rotation, rot); //元件的新的数值
xscal = Math.sqrt((x-this._x)*(x-this._x)+(y-this._y)*(y-this._y));
this._xscale = xscal; //Math.sqrt用来取平方根,这个是两点之间线的长度,把鼠标与场景中的影片的距离作为影片在横坐标方向的缩放值,就是说鼠标离影片越远,影片剪辑在横坐标方向上放大程度越大
updateAfterEvent(); //影片剪辑执行完成后,更新显示内容,也就是刷新的意思。
}
图8

好了,完成,测试下吧~