Flash教程:飞舞的两只蝴蝶2
9.新建一个图层改名为action,然后按F9打开动作面板,输入如下动作:
probability = 100;
scene_width = 500;
scene_height = 290;
speed = 0.03;
depth = 15;
MovieClip.prototype.smoothMove = function (speed, targetx, targety) {
this._x += speed*(targetx-this._x);
this._y += speed*(targety-this._y);
};
MovieClip.prototype.rotateTo = function (targetx, targety) {
var diffX = targetx-this._x;
var diffY = targety-this._y;
this._rotation = Math.atan2 (diffY, diffX)*180/Math.PI;
};
_root.transp0.onEnterFrame = function () {
if (random (probability) == 1) {
target0X = random (scene_width);
target0Y = random (scene_height);
}
this._visible = 0;
this.smoothMove (speed, target0X, target0Y);
};
_root.transp1.onEnterFrame = function () {
if (random (probability) == 1) {
target1X = random (scene_width);
target1Y = random (scene_height);
}
this._visible = 0;
this.smoothMove (speed, target1X, target1Y);
};
_root.fly0_mc.onEnterFrame = function () {
this.smoothMove (speed, transp0._x, _root.transp0._y);
this.rotateTo (_root.transp0._x, _root.transp0._y);
};
_root.fly1_mc.onEnterFrame = function () {
this.smoothMove (speed, transp1._x, _root.transp1._y);
this.rotateTo (_root.transp1._x, _root.transp1._y);
};
_root.shadow0_mc.onEnterFrame = function () {
this.smoothMove (speed, transp0._x, _root.transp0._y+depth);
this.rotateTo (_root.transp0._x, _root.transp0._y+depth);
};
_root.shadow1_mc.onEnterFrame = function () {
this.smoothMove (speed, transp1._x, _root.transp1._y+depth);
this.rotateTo (_root.transp1._x, _root.transp1._y+depth);
};
动画制作完成,按Ctrl+回车键可以测试动画了!Thank you!有兴趣的同学赶紧试一试吧!
Word教程网 | Excel教程网 | Dreamweaver教程网 | Fireworks教程网 | PPT教程网 | FLASH教程网 | PS教程网 |
HTML教程网 | DIV CSS教程网 | FLASH AS教程网 | ACCESS教程网 | SQL SERVER教程网 | C语言教程网 | JAVASCRIPT教程网 |
ASP教程网 | ASP.NET教程网 | CorelDraw教程网 |