CREATE : 25-12-05


I do this work for answer a question in TFD about drawing circle and after I finish for method, I just know that it can apply for create polygon too, so I apply code to be polygon drawing method.

In this work I try to use many technique such as prototype , recursive function, setInterval and drawing API function. At first I got original code in kirupa tutorial which teach about circular movement and I use that code for developing.

About method you can drawing polygon in all timeline that you want (I have test for only main timeline first). It still don't support for direction of drawing, but not so hard to modify.

About this work I try to draw many polygon in movieclip that create by "createEmptyMovieClip" and I try to random for quantity too. A problem that I found is that cause error when I press on create button many times while polygon still don't finished drawing. The problem is setInterval function still run and don't know object to reference, so I have to check for finishing of drawing and enable button to click again. (Other method is clearInterval for all ID before remove movieclip).

I have ever coded snow method that I tried to create "recusive setInterval function". So I use that code for doing with this work and look interesting.

This is source for polygonDrawing (copy and place on main timeline)

MovieClip.prototype.drawPolygon = function(side, xcenter, ycenter, radius, degree, thickness, color, alpha, speed, path, option) {
if (option == undefined) {
if (arguments.length != 9) {
trace("parameter not correct")
return "";
this.point = {side:side, radius:radius, speed:speed, xcenter:xcenter, ycenter:ycenter, degree:degree, degreeCollect:0};
this.lineStyle(thickness, color, alpha);
var radian = (this.point.degree/180)*Math.PI;
this.moveTo(this.point.xcenter+Math.cos(radian)*this.point.radius, this.point.ycenter-Math.sin(radian)*this.point.radius);
this.point.ID1 = setInterval(drawPolygon, 0, side, xcenter, ycenter, radius, degree, thickness, color, alpha, speed, this, "1");
} else if (option == "1") {
path.point.ID2 = setInterval(drawPolygon, speed, side, xcenter, ycenter, radius, degree, thickness, color, alpha, speed, path, "2");
} else if (option == "2") {
with (path.point) {
var drawS = 360/side;
degree += drawS;
degreeCollect += drawS;
var radian = (degree/180)*Math.PI;
x = xcenter+Math.cos(radian)*radius;
y = ycenter-Math.sin(radian)*radius;
path.lineTo(x, y);
if (degreeCollect>=360) {
delete path.point;
_root.drawPolygon(5, 100, 100, 50, 20, 2, 0x006666, 100, 50);

and when you want to draw you can write as here.

path.drawPolygon(side, xcenter, ycenter, radius, degree, thickness, color, alpha, speed)

side : quantity of size of polygon.

xcenter: center point of polygon in x axis

ycenter: center point of polygon in y axis

radius: radius of polygon (from center to first drawing point)

thinkness, color, alpha : properties of polygon.

speed: speed of drawing (Interval time for setInterval function. Low number make it fast drawing)




Thanks a lot for the facts just about this good topic! That’s obviously that the term paper writing service would present the essay writing. So, that is a great possibility to buy term paper or custom essay about this topic.
#3 by custom essay ( At 2011-11-26 12:39,
Different people get know that it is easier to purchase the thesis abstract or thesis close to this post, than to create by personal efforts.
#2 by thesis writing ( At 2011-11-24 12:03,
Do you understand that it is correct time to receive the mortgage loans, which will make your dreams come true.
#1 by KirstenBarry ( At 2011-11-22 23:25,