Script Membuat lingkaran dengan AS2

Bismillah..

Contoh script membuat lingkaran :

Bisa dilihat di situs : google.com, kata kunci ‘circle with as2’

Berikut salah satu contoh hasil pencarian dari actionscript.org

MovieClip.prototype.drawCircle = function(center, rad, fillColor, fillAlpha, lineColor, lineAlpha, lineWidth) {
trace(center[0]+”, “+center[1]+”, “+rad+”, “+fillColor+”, “+fillAlpha+”, “+lineColor+”, “+lineAlpha+”, “+lineWidth);
controlOffset = Math.sin(24*Math.PI/180)*rad;
if (!fillColor) {
// if fillColor is not specified black is assigned @ alpha 100%
fillColor = 0x000000;
fillAlpha = 100;
}
if (lineColor) {
// if lineColor is specified a line is drawn, if not not
// if lineWidth is not specified width is set @ 1 pixel
// if lineAlpha is not specified alpha is set @ 100%
lineStyle(lineWidth+1*(lineWidth == undefined), lineColor, lineAlpha+100*(lineAlpha == undefined));
}
beginFill(fillColor, fillAlpha);
moveTo(center[0], center[1]-rad);
curveTo(center[0]+controlOffset, center[1]-rad, center[0]+Math.cos(45*Math.PI/180)*rad, center[1]-Math.sin(45*Math.PI/180)*rad);
curveTo(center[0]+rad, center[1]-controlOffset, center[0]+rad, center[1]);
curveTo(center[0]+rad, center[1]+controlOffset, center[0]+Math.cos(45*Math.PI/180)*rad, center[1]+Math.sin(45*Math.PI/180)*rad);
curveTo(center[0]+controlOffset, center[1]+rad, center[0], center[1]+rad);
curveTo(center[0]-controlOffset, center[1]+rad, center[0]-Math.cos(45*Math.PI/180)*rad, center[1]+Math.sin(45*Math.PI/180)*rad);
curveTo(center[0]-rad, center[1]+controlOffset, center[0]-rad, center[1]);
curveTo(center[0]-rad, center[1]-controlOffset, center[0]-Math.cos(45*Math.PI/180)*rad, center[1]-Math.sin(45*Math.PI/180)*rad);
curveTo(center[0]-controlOffset, center[1]-rad, center[0], center[1]-rad);
endFill();
};
_root.drawCircle([150, 150], 100, 0xFF0000, 100, 0x0000FF, 100, 4);

MovieClip.prototype.drawCircle = function(center, rad, fillColor, fillAlpha, lineColor, lineAlpha, lineWidth) {
    trace(center[0]+", "+center[1]+", "+rad+", "+fillColor+", "+fillAlpha+", "+lineColor+", "+lineAlpha+", "+lineWidth);
    controlOffset = Math.sin(24*Math.PI/180)*rad;
    if (!fillColor) {
        // if fillColor is not specified black is assigned @ alpha 100%
        fillColor = 0x000000;
        fillAlpha = 100;
    }
    if (lineColor) {
        // if lineColor is specified a line is drawn, if not not
        // if lineWidth is not specified width is set @ 1 pixel
        // if lineAlpha is not specified alpha is set @ 100%
        lineStyle(lineWidth+1*(lineWidth == undefined), lineColor, lineAlpha+100*(lineAlpha == undefined));
    }
    beginFill(fillColor, fillAlpha);
    moveTo(center[0], center[1]-rad);
    curveTo(center[0]+controlOffset, center[1]-rad, center[0]+Math.cos(45*Math.PI/180)*rad, center[1]-Math.sin(45*Math.PI/180)*rad);
    curveTo(center[0]+rad, center[1]-controlOffset, center[0]+rad, center[1]);
    curveTo(center[0]+rad, center[1]+controlOffset, center[0]+Math.cos(45*Math.PI/180)*rad, center[1]+Math.sin(45*Math.PI/180)*rad);
    curveTo(center[0]+controlOffset, center[1]+rad, center[0], center[1]+rad);
    curveTo(center[0]-controlOffset, center[1]+rad, center[0]-Math.cos(45*Math.PI/180)*rad, center[1]+Math.sin(45*Math.PI/180)*rad);
    curveTo(center[0]-rad, center[1]+controlOffset, center[0]-rad, center[1]);
    curveTo(center[0]-rad, center[1]-controlOffset, center[0]-Math.cos(45*Math.PI/180)*rad, center[1]-Math.sin(45*Math.PI/180)*rad);
    curveTo(center[0]-controlOffset, center[1]-rad, center[0], center[1]-rad);
    endFill();
};
_root.drawCircle([150, 150], 100, 0xFF0000, 100, 0x0000FF, 100, 4);

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s