用纯Flash Actionscript做的火柴棍小人跑的动画

非常有趣,本教程描绘的是完全用ActionScript做的一个火柴棍小人跑步的动画,你相信吗?完全是AS实现的。
先看效果吧


做的方法非常简单,直接把下面代码复制到第一帧,最好把帧频调到18fps。
以下为引用的内容:
fscommand("allowscale", false);
fscommand("showmenu", false);
lineStyle(1, 0x000000, 100);
moveTo(0, 135);
lineTo(550, 135);
moveTo(0, 185);
lineTo(550, 185);
lineStyle(2, 0x000000, 100);
moveTo(26, 16);
lineTo(37, 16);
lineTo(37, 39);
curveTo(28, 43, 33, 67);
moveTo(37, 16);
lineTo(26, 24);
moveTo(37, 24);
lineTo(26, 31);
moveTo(37, 32);
lineTo(26, 40);
moveTo(41, 15);
lineTo(53, 14);
lineTo(53, 39);
curveTo(39, 45, 50, 66);
moveTo(53, 14);
lineTo(42, 21);
moveTo(53, 23);
lineTo(42, 28);
moveTo(53, 31);
lineTo(42, 38);
moveTo(27, 75);
lineTo(27, 90);
lineTo(39, 92);
moveTo(33, 74);
lineTo(33, 91);
moveTo(38, 74);
lineTo(38, 83);
lineTo(33, 84);
moveTo(33, 95);
curveTo(41, 113, 48, 94);
moveTo(41, 94);
lineTo(41, 127);
moveTo(30, 124);
curveTo(38, 84, 51, 125);
moveTo(55, 75);
curveTo(36, 69, 46, 92);
moveTo(49, 75);
curveTo(48, 86, 55, 92);
work_tree = function (tree_NO, speed_time) {
this.createEmptyMovieClip("tree" tree_NO, tree_NO);
// trace("tree_name=" "tree" tree_NO);
tellTarget ("tree" tree_NO) {

lineStyle(1, 0x000000, 100);
moveTo(0, -54);
curveTo(-21, -42, -23, -20);
curveTo(-18, 17, -5, 24);
lineStyle(1, 0x000000, 100);
moveTo(0, -54);
curveTo(22, -42, 23, -20);
curveTo(18, 17, 5, 24);

lineStyle(0.25, 0x000000, 100);
moveTo(-5, 24);
lineTo(-5, -7);
curveTo(1, 5, 5, -8);
lineTo(5, 24);
lineStyle(1, 0x000000, 100);
moveTo(-5, 24);
lineTo(-5, 55);
lineTo(5, 55);
lineTo(5, 24);
// ------------
this["tree" tree_NO]._xscale = speed_time;
this["tree" tree_NO]._yscale = speed_time;
this["tree" tree_NO]._alpha = speed_time-20;
this["tree" tree_NO]._y = 75;
this["tree" tree_NO].onEnterFrame = function() {
this._x = this._x speed_time/15;
if (this._x>=500) {
this.clear();
this.onEnterFrame = undefined;
this.removeMovieClip();
}
};
}
};
work_play_caput = function (path) {
this[path].createEmptyMovieClip("play_caput", 2000);
tellTarget (this[path]["play_caput"]) {
lineStyle(0.25, 0x000000, 100);
beginFill(0x000000, 100);
moveTo(0, -10);
curveTo(-10, -8, -10, 0);
curveTo(-8, 10, 0, 10);
curveTo(10, 8, 10, 0);
curveTo(8, -10, 0, -10);
}
};
work_play1_run = function (x, y, xscale, yscale) {
this.createEmptyMovieClip("play1_run", 1000);
work_play_caput("play1_run");
play1_run._xscale = xscale;
play1_run._yscale = yscale;
play1_run._x = x;
play1_run._y = y;
tellTarget ("play1_run") {
play_caput._xscale = 65;
play_caput._yscale = 65;
play_time = 0;
this.play1_run.onEnterFrame = function() {
this.play_time ;
tellTarget (this) {
if (play_time == 1) {
clear();
play_caput._x = 17;
play_caput._y = 5;
lineStyle(3, 0x000000, 100);
moveTo(15, 10);
lineTo(7, 15);
lineTo(2, 22);
moveTo(15, 10);
lineTo(20, 17);
lineTo(28, 17);

moveTo(15, 10);
lineTo(12, 20);
lineTo(12, 28);

moveTo(12, 28);
lineTo(7, 40);
lineTo(0, 45);
lineTo(3, 48);

moveTo(12, 28);
lineTo(20, 35);
lineTo(15, 40);
lineTo(16, 42);
} else if (play_time == 3) {
clear();
play_caput._x = 23;
play_caput._y = 5;
lineStyle(3, 0x000000, 100);

moveTo(21, 11);
lineTo(10, 14);
lineTo(5, 20);

moveTo(21, 11);
lineTo(27, 18);
lineTo(35, 15);

moveTo(21, 11);
lineTo(18, 20);
lineTo(16, 30);

moveTo(16, 30);
lineTo(10, 35);
lineTo(1, 40);
lineTo(0, 43);

moveTo(16, 30);
lineTo(22, 33);
lineTo(27, 41);
lineTo(30, 43);
} else if (play_time == 5) {
clear();
play_caput._x = 25;
play_caput._y = 5;
lineStyle(3, 0x000000, 100);

moveTo(22, 11);
lineTo(10, 16);
lineTo(8, 24);

moveTo(22, 11);
lineTo(25, 20);
lineTo(32, 18);

moveTo(22, 11);
lineTo(18, 21);
lineTo(18, 30);

moveTo(18, 30);
lineTo(10, 35);
lineTo(2, 35);
lineTo(0, 36);

moveTo(18, 30);
lineTo(22, 36);
lineTo(25, 47);
lineTo(30, 47);
} else if (play_time == 7) {
clear();
play_caput._x = 18;
play_caput._y = 6;
lineStyle(3, 0x000000, 100);

moveTo(15, 11);
lineTo(13, 18);
lineTo(16, 20);

moveTo(15, 11);
lineTo(11, 18);
lineTo(14, 25);

moveTo(15, 11);
lineTo(12, 20);
lineTo(11, 25);
moveTo(11, 25);
lineTo(16, 36);
lineTo(9, 36);
lineTo(10, 38);

moveTo(11, 25);
lineTo(12, 35);
lineTo(10, 45);
lineTo(13, 45);
} else if (play_time == 8) {
play_time = 0;
}
}
};
}
};
work_play2_arise = function () {
this.createEmptyMovieClip("play2_arise", 2000);
work_play_caput("play2_arise");
tellTarget ("play2_arise") {
play_caput._x = 2;
play_caput._y = -20;
lineStyle(4, 0x000000, 100);

moveTo(-7, -5);
lineTo(6, -7);

moveTo(-4, -9);
lineTo(5, -3);

moveTo(1, -11);
lineTo(0, 10);
moveTo(0, 10);
lineTo(1, 23);
lineTo(-3, 35);
lineTo(2, 35);
moveTo(0, 10);
lineTo(-6, 21);
lineTo(4, 29);
lineTo(1, 33);
}
};
player_run = function () {
clear();
lineStyle(5, 0x000000, 100);
moveTo(sx, sy);
lineTo(zs1x, zs1y);
lineTo(zs2x, zs2y);
moveTo(sx, sy);
lineTo(ys1x, ys1y);
lineTo(ys2x, ys2y);
moveTo(sx, sy);
lineTo(st1x, st1y);
lineTo(st2x, st2y);
moveTo(st2x, st2y);
lineTo(zj1x, zj1y);
lineTo(zj2x, zj2y);
lineTo(zj3x, zj3y);
moveTo(st2x, st2y);
lineTo(yj1x, yj1y);
lineTo(yj2x, yj2y);
lineTo(yj3x, yj3y);
setProperty("/tou2", _x, toux2);
setProperty("/tou2", _y, touy2);
lineStyle(5, 0x930093, 100);
moveTo(sx2, sy2);
lineTo(zs1x2, zs1y2);
lineTo(zs2x2, zs2y2);
moveTo(sx2, sy2);
lineTo(ys1x2, ys1y2);
lineTo(ys2x2, ys2y2);
moveTo(sx2, sy2);
lineTo(st1x2, st1y2);
lineTo(st2x2, st2y2);
moveTo(st2x2, st2y2);
lineTo(zj1x2, zj1y2);
lineTo(zj2x2, zj2y2);
lineTo(zj3x2, zj3y2);
moveTo(st2x2, st2y2);
lineTo(yj1x2, yj1y2);
lineTo(yj2x2, yj2y2);
lineTo(yj3x2, yj3y2);
};
//---------------------new_load_data---------------------
tree_play_time = 0;
tree_NO = 0;
play_time = 0;
//work_play_caput();
//play_caput._visible = false;
//---------------------start_play---------------------
trees_play = function () {
// ↓每当播放速度值达到15时 复制一棵树
if (tree_play_time == 15) {
// ↓随机产生每一棵树的大小及移动的速度
speed_time = int(random(50)) 30;
// 制造树
work_tree(tree_NO, speed_time);
tree_NO ;
tree_play_time = 0;
}
tree_play_time ;
};
this.onEnterFrame = function() {
play_time ;
//放置人物1跑动
if (play_time == 1) {
work_play1_run(319, 94, -150, 150);
}
//树移动
trees_play();
};

按Ctrl Enter测试吧!

用纯Flash Actionscript做的火柴棍小人跑的动画

上一篇:Photoshop 精致的金属锅制作方法


下一篇:Photoshop打造梦幻的彩色光斑壁纸实例