1. Draw Animating Circle
var cnt:Number = -90; // from which degree
var radius:Number = 100;
this.createEmptyMovieClip("circle",this.getNextHighestDepth());
circle._x = 200;
circle._y = 200;
circle.lineStyle(1,0xFF0000,100);
xx = 100*Math.cos(-90*Math.PI/180);
yy = 100*Math.sin(-90*Math.PI/180);
circle.moveTo(xx,yy);
intervalId = setInterval(this, "executeCallback", 5);
// function to darw a circele.
function executeCallback() {
xx = 100*Math.cos(cnt*Math.PI/180);
yy = 100*Math.sin(cnt*Math.PI/180);
circle.lineTo(xx,yy);
cnt++;
if (cnt>=270) {
fillcolor();
circle.endFill();
clearInterval(intervalId);
}
}
// To fill the color to circle
function fillcolor() {
circle.beginFill(0x00ff00,50);
for (var i = -90; i<=270; i++) {
xx = 100*Math.cos(i*Math.PI/180);
yy = 100*Math.sin(i*Math.PI/180);
circle.lineTo(xx,yy);
}
}
2. Drawing Rectangle and Square
this.createEmptyMovieClip("rectangle_mc", 1);
with(rectangle_mc){
lineStyle(6, 0x003399, 100);
moveTo(0, 0);
lineTo(200, 0);
lineTo(200, 200);
lineTo(0, 200);
lineTo(0, 0);
_x=80;
_y=80;
}
3. Draw Arc
//
function drawArc(centerX, centerY, radius, startAngle, arcAngle, steps){
//
// Rotate the point of 0 rotation 1/4 turn counter-clockwise.
startAngle -= .25;
//
var twoPI = 2 * Math.PI;
var angleStep = arcAngle/steps;
var xx = centerX + Math.cos(startAngle * twoPI) * radius;
var yy = centerY + Math.sin(startAngle * twoPI) * radius;
moveTo(xx, yy);
for(var i=1; i<=steps; i++){
var angle = startAngle + i * angleStep;
xx = centerX + Math.cos(angle * twoPI) * radius;
yy = centerY + Math.sin(angle * twoPI) * radius;
lineTo(xx, yy);
}
}
lineStyle(0, 0xFF0000);
drawArc(250, 250, 200, 45/360, -90/360, 20);
//
4. Draw Triangle
_root.lineStyle(3, 0x0000FF, 100); _root.moveTo(50, 200);
_root.lineTo(150, 50);
_root.lineTo(250, 200);
_root.lineTo(50, 200);
5. Draw Pentagon
createEmptyMovieClip("pentagon_mc", 1);
pentagon_mc.beginFill(0x999999, 85);
pentagon_mc.moveTo(0, 0);
pentagon_mc.lineTo(0, -60);
pentagon_mc.lineTo(-60, 0);
pentagon_mc.lineTo(-60, 60);
pentagon_mc.lineTo(60, 60);
pentagon_mc.lineTo(60, 0);
pentagon_mc.lineTo(0, -60);
pentagon_mc.endFill();
6. Draw Dimond
createEmptyMovieClip("diamond_mc", 1);
diamond_mc.beginFill(0x000000, 100);
diamond_mc._x=300;
diamond_mc._y=100;
diamond_mc.lineTo(0, -90);
diamond_mc.lineTo(-90, 0);
diamond_mc.lineTo(0, 90);
diamond_mc.lineTo(90, 0);
diamond_mc.lineTo(0, -90);
diamond_mc.endFill();
7. Draw Oval Shape
// Change "radius" to "xRadius" and add "yRadius" argument.
function drawOval(centerX, centerY, xRadius, yRadius, sides){
//
// Change "radius" to "xRadius".
this.moveTo(centerX + xRadius, centerY);
//
for(var i=0; i<=sides; i++){
var pointRatio = i/sides;
var radians = pointRatio * 2 * Math.PI;
var xSteps = Math.cos(radians);
var ySteps = Math.sin(radians);
//
// Change "radius" to "xRadius".
var pointX = centerX + xSteps * xRadius;
//
// Change "radius" to "yRadius".
var pointY = centerY + ySteps * yRadius;
//
this.lineTo(pointX, pointY);
}
}
//
lineStyle(0);
//
// X, Y, W, H, steps.
drawOval(250, 200, 200, 150, 100);
//

RSS Feeds
Feed Comment 




Leave Your Comments Below