Cat Chasing Sausage (Adobe Flash Actionscript Animation)
by 131111 in Craft > Digital Graphics
548 Views, 3 Favorites, 0 Comments
Cat Chasing Sausage (Adobe Flash Actionscript Animation)
simple code in action script 2.0
Short Notes
Follow Short Notes
Notes...
Copy All
setProperty("", _quality, "MEDIUM");
N = 20;
R = 12;
C = 2;
A = 2;
var x = new Array();
var y = new Array();
for (i = 0; i < N; i++)
{
x[i] = 0;
y[i] = 0;
} // end of for
for (i = 1; i < N; i++)
{
if (i == 1)
{
attachMovie("three", "Pieza" + i, N + 1 - i);
}
else if (i == 4 || i == 14)
{
attachMovie("two", "Pieza" + i, N + 1 - i);
}
else
{
attachMovie("one", "Pieza" + i, N + 1 - i);
} // end else if
this["Pieza" + i]._x = 142 + x[i - 1];
this["Pieza" + i]._y = 142 + y[i - 1];
this["Pieza" + i]._xscale = 102 + A * (1 - i);
this["Pieza" + i]._yscale = 102 + A * (1 - i);
this["Pieza" + i]._alpha = 100 - 100 / N * i;
} // end of for
Copy All
x[0] = x[0] + (_xmouse - x[0] - 142) / R;
y[0] = y[0] + (_ymouse - y[0] - 142) / R;
for (i = 1; i < N; i++)
{
x[i] = x[i] + (x[i - 1] - x[i]) / C;
y[i] = y[i] + (y[i - 1] - y[i]) / C;
} // end of for
for (i = 1; i < N; i++)
{
this["Pieza" + i]._x = 142 + (x[i - 1] + x[i]) / 2;
this["Pieza" + i]._y = 142 + (y[i - 1] + y[i]) / 2;
this["Pieza" + i]._rotation = 5.729578E+001 * Math.atan2(y[i] - y[i - 1], x[i] - x[i - 1]);
} // end of for
Copy All. to Test, Hit Ctrl + Enter
gotoAndPlay(2);
The Sausage. Done.
cursor_mc.startDrag("true");
Mouse.hide();
Optional.
Sorry if it's too long. Thank you for following it to the end.