Groups | Blog | Home
all groups > flash (macromedia) > september 2004 >

flash (macromedia) : draw api square with round corners


Pluda
9/30/2004 9:46:31 PM
Hello,

can somebody help me with the draw api?

I know how to make an square, or an ovel, but I need one square whit round
corners, and this I can't make...

Could somebody point me to the right way of making this?

Thanks
urami_
10/1/2004 8:02:23 AM

[quoted text, click to view]

first paste to timeline frame


_global.drawBorder = function
(movieClip,colour,padding,weight,radius,width,height,alpha,fill,fillColor,offset)
{
padding = parseInt(padding);
radius = parseInt(radius);
width = parseInt(width);
height = parseInt(height);
xAxis1 = -padding + offset;
xAxis2 = -padding+radius + offset;
xAxis3 = width+padding-radius + offset;
xAxis4 = width+padding + offset;
yAxis1 = -padding + offset;
yAxis2 = -padding+radius + offset;
yAxis3 = height+padding-radius + offset;
yAxis4 = height+padding + offset;
if(fill == 1){
movieClip.beginFill(fillColor,alpha);
}
movieClip.lineStyle(weight,colour,alpha);
movieClip.moveTo(xAxis2,yAxis1);
movieClip.lineTo(xAxis3,yAxis1);
movieClip.curveTo(xAxis4,yAxis1,xAxis4,yAxis2);
movieClip.lineTo(xAxis4,yAxis3);
movieClip.curveTo(xAxis4,yAxis4,xAxis3,yAxis4);
movieClip.lineTo(xAxis2,yAxis4);
movieClip.curveTo(xAxis1,yAxis4,xAxis1,yAxis3);
movieClip.lineTo(xAxis1,yAxis3);
movieClip.lineTo(xAxis1,yAxis2);
movieClip.curveTo(xAxis1,yAxis1,xAxis2,yAxis1);
movieClip.lineTo(xAxis2,yAxis1);
if(fill == 1){
movieClip.endFill();
}
};


Now , if you want to draw anytihng , simply :

//box 1
_root.createEmptyMovieClip("box1", 0);
box1._x = 20;
box1._y = 20;
drawBorder(box1,0x333333,0,1,6,200,200,100,true,0x99FF99, 0);


or another box :

//box 2
_root.createEmptyMovieClip("box2", 1);
box2._x = 20;
box2._y = 115;
drawBorder(box2,0x333333,0,1,6,250,75,100,true,0x999999, 0.5);

Play around with paramters, define color , size and location at will...
--


Regards


urami_*

<hol>
http://flashfugitive.com/
</hol>


By The way:
If you try to mail me , DO NOT *laugh*
David Stiller
10/1/2004 9:08:34 AM
For additional info and source code, check out Ric Ewing's article at
http://www.macromedia.com/devnet/mx/flash/articles/adv_draw_methods.html


David
stiller ( at ) quip ( dot ) net

Pluda
10/2/2004 12:59:12 AM
Hello,

Thanks you both for your replyes!

AddThis Social Bookmark Button