Learn how to apply sine and cosines function for creating some pictures by Drawing API. You will also learn how to use Action Script panel and more.Note! For this tutorial, I have used Macromedia Flash Mx 2004.
Example 1Create a new flash document and go to the Action Script Panel (F). After that, enter the following action script code inside the actions panel:
_root.createEmptyMovieClip("circle", 1);
circle._y = 200;
circle._x = 75; circle.lineStyle(5,2);
for (i = 0; i < Math.PI * 6; i += 0.03)
{
x = Math.cos(i) * 70;
y = Math.sin(i) * 70;
circle.moveTo(x,y);
circle.lineTo(x + 1, y);
}
This Script will Generate a circle:
Example 2This Script will Generate some shape:
_root.createEmptyMovieClip("shape", 1);
shape._y = 200;
shape._x = 75;
shape.lineStyle(3,0);
for (i = 0; i < Math.PI * 6; i += 0.01)
{
x = Math.cos(i / 3) * 70;
y = Math.sin(i) * 70;
shape.moveTo(x,y);
shape.lineTo(x + 1, y);
}
Example 3This Script will Generate another shape:
_root.createEmptyMovieClip("shape", 1);
shape._y = 200;
shape._x = 75; shape.lineStyle(3,0);
for (i = 0; i < Math.PI * 18; i += 0.1)
{
x = Math.cos(i / 3) * 70;
y = Math.sin(i / 4) * 70;
shape.moveTo(x,y);
shape.lineTo(x + 1, y);
}
Example 4This Script will Generate sinus wave:
_root.createEmptyMovieClip("sinus", 1);
sinus._y = 130;
sinus._x = 75; sinus.lineStyle(3,0);
for (i = 0; i < Math.PI * 4; i += 0.01)
{
x = i*40;
y = Math.sin(i) * 70;
sinus.moveTo(x,y);
sinus.lineTo(x + 1, y);
}