Feb 15 2009

AS3 resizable curved box with gradients Final

Category: ClassesHadi Tavakoli @ 7:13 pm

in my last post I tried to create curved boxes with a VERY bad practice! and although after I lernt about "DrawRoundRect" I wanted to continue with my other class but now I decided to use the new method because this one is cleaner and more understanable and as we are going ahead, our application will get very heavy so we must save as much CPU as we can. So now I created the very same curved box with gradient colors but this time we will do it all in codes and we won't create any premade movieclips in the library like what we did in the last post here.

This is the class saved with the name of "CurvedRectacgle.as".


		  
		  
		  
		  
		  
		  
		

and whenever you want to draw your curved box with the gradient color in it, you may use it like this:


		  
		  
		  
		  
		  
		  
		

Using this method will save us a lot of CPU and also KB as we are not using all those movieclips in the library and besides that, this class all uses the Sprite and no movieclips involved here :) I'm sure this version is a lot better, don't you?

Regards,
Hadi

Tags: , , , , , , , ,


Feb 14 2009

AS3 resizable curved box with gradients

Category: ClassesHadi Tavakoli @ 10:39 pm

Have you ever wished you could have a resizable curved cornered box which you could easily change its gradient colors?! Find the new Class for this here.

well, if so, I'm sure you have tested it and have found out that creating a well shaped curved cornered box in a movieclip will not look good when you try to resize the movieclip! the corners get disordered...

download this class I wrote today (Saved in CS4), it will let you create boxes and set their size plus their gradient color easilly and add it anywhere you like :)


		  
		  
		  
		  
		  
		  
		

And here is how it may look...

When I give it a second thought, maybe we can add even more features to this simple class... but that's ok for my current use. I hope someone can find this helpful as it gives a good sample on drawing gradients and also about the logic behind how we have saved the curved corners of a box!

Here is the class for a quick review:


		  
		  
		  
		  
		  
		  
		

If you ever came up with a better version, I'd be glad to have a look also :)

Regards,
Hadi

Tags: , , , , , , , ,