11. Drawing a Circle
Procedure:step 1: Open flash 8
step 2: Select flash document
step 3: select 1st layer, 1st frame on that document and write source code on Actions Frame
step 4: To check output press ctrl+enter(test movie)
Source code:
function drawcircle(r,x,y)
{
this.createEmptyMovieClip("circle_mc",1);
with(circle_mc)
{
var angle=Math.PI/4;
var d=r/Math.cos(angle/2);
var angle1=0;
var rx,ry,ax,ay;
this.moveTo(x+r,y);
for(var i=0;i<8;i++)
{
angle1+=angle;
rx=x+Math.cos(angle1-(angle/2))*d;
ry=y+Math.sin(angle1-(angle/2))*d;
ax=x+Math.cos(angle1)*r;
ay=y+Math.sin(angle1)*r;
this.lineStyle(0,0x0000FF,100);
this.curveTo(rx,ry,ax,ay);
}
}
}
drawcircle(100,100,100);
No comments:
Post a Comment