Rounded rectangles with drawing API

Peter has just posted a code snippet that you can use to make rounded rectangles using the Drawing API at the Flash MX 2004 forums. Check out the code snippet here:

http://flashmx2004.com/forums/index.php?act=ST&f=18&t=3847&st=0#entry15248

Posted by jen on July 24, 2004 at 05:54 PM
Comments

*cough*

http://chattyfig.figleaf.com/flashcoders-wiki/index.php?CodeOnlyRoundedRectangle

>(last edited September 7, 2002)

Posted by: Mario Klingemann at July 25, 2004 04:54 AM

sorry, i didnt know one was already on the internet. i'll delete mine immediately.

Posted by: peter at July 25, 2004 12:21 PM

Delete it? Just must be joking - that was not my intention of my comment. Fortunately there is no such thing yet as patents on rounded rectangles. Also your's is AS 2.0.

Posted by: Mario Klingemann at July 25, 2004 01:04 PM

this is already in the as 2.0 code library under the following location:

mx.skins.halo.Defaults

drawRoundRect(x,y,w,h,r,c,alpha,rot,gradient,ratios)

on calling the classConstruct(), this function is available in the UIObject class or anything that inherits from it, ie. every component.

each version is different so is nice to have all available...

nik
nik@nuthing.com

Posted by: Nik Khilnani at July 26, 2004 08:51 AM

see also:
http://www.macromedia.com/devnet/mx/flash/articles/adv_draw_methods.html

and:
http://www.alex-uhlmann.de/flash/animationpackage/index.htm

Posted by: colin moock at July 26, 2004 09:56 AM

Thanks Nik,

I checked into that method in the Defaults.as class and did some playing around with it. Basically just copied the method into a new empty FLA and tried to check out how it was better. They seem to support gradient stuff which i didn't even consider, but in the end it looks like the green rectangle that they created was almost pixel per pixel the same that my code created.

So, their code is a lot more "robust" but is about 77 lines of code, whereas mine is basic and not very good, but at least it is small at about 18 lines of code. Compromises either way.

Thanks for the heads up, great work.

peter

Posted by: peter at July 26, 2004 11:00 AM

Great links Colin!
the drawing methods look fantastic. The first link seems to be ActionScript 1 based and use _root a bit in the FLA, but should be easy enough to swap that out.

And the animation package looks fantastic, definitely worth checking out.

thanks all

Posted by: peter at July 26, 2004 01:02 PM

Noticed another new feature with the 7.2 upgrade. In addition to the Polygonal drawing tool that came with Flash 7.0, a new tool has been added, the GitterRect tool.

Quick way to add a grid image but... what else?

Posted by: h8ids at July 30, 2004 11:00 AM

The new version of AnimationPackage (1.01) offers a new RoundRectangle class that allows you to set a corner radius for all corners individually and modify the registration point.

all the improvements in version 1.01:
http://www.alex-uhlmann.de/flash/animationpackage/history.htm

cheers,
Alex

Posted by: AlexU at August 2, 2004 11:02 AM