Rough edges rectangle class

February 25th, 2010 by Slav

For a recent project I needed to create buttons with rough edges background. Gave it a quick google and couldn’t find a class for this, so I made a new one.

Demo

It uses drawPath command so requires flash plugin ver 10.

here’s the constructor :

/**
* @param w: width
* @param h: height
* @param col: background color
* @param distortion: amount of edges distortion (wawe-iness)
* @param density : density of distored vertexes
*/
new RoughEdgedRectangle(w, h, col, distortion, density);

so to create and add to stage you simply call something like :var sq:RoughEdgedRectangle = new RoughEdgedRectangle(500,250,0xFF00FF,3,100);
addChild(sq);
 

I made this little demo app that gives a visual preview of what the changing parameters does. It has view source enabled so you can download the source code.

Posted in flash | 3 Comments »