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?
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...
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
in my other post we created a Box class http://www.emstris.com/category/classes/box/ where we managed to set a box of information with actually three elements, a thumbnail, a title and some space for the details.
In that Box class you where able to create any size boxes and put anything in them but using that class alone will not be very helpful if you are trying to build a playlist or something! right?
So I thought of creating an itemList which can easilly add these boxes in a class which will extend MovieClip so it will be a lot easy to pile up the boxes and insert data into them.
let's take a look at our itemList now:
And with the help of below code we will create new instances of our item list:
This ItemList class is actually a MovieClip as we are extending MovieClip and it can be placed anywhere. As you see above we have first initialised the class and then have set diffrent properties to be used later in every instance of the Box class which we will later import through the ItemList class.
Take a look at the ItemClass itself and you will find a couple of interesting things around... hehehe, maybe you won't call creating of custom listener an interesting thing! but as this is actually the first time I am creating them, I am very excited that I am planing to post a complete new topic about them! Anyway, here is the item list class:
If you ask me to summarize the whole thing, I can say that all this item list class does, is to create new instances of the Box class and insert the data into them! But I also added a couple of useful features into it like how you click on an item and it gets highlighted, and how you can set one of the items as the default selected item, and also the most beautiful part from my eyes which is the "dispatchEvent(new Event("itemChanged"));" As promised, I will talk about how custom event listeners work later in my next post.
After you play a bit with this item list I am sure you will quickly say that this item list will look better if we can put it under a scrollbar... yeah, of course you're right, and why don't you do that yourself?!
in my scrollbar class here I have made it in a way that enables you to drop any movieclip under the scrollbar so why don't you try and drop the item list under it? well, later when I post my dropdown menu class, you will see how we are managing to combine all of our different classes and put them all work together in a dropdown menu! keep checking back and you will see some more useful stuff around here... I guess we are really making a progress in AS3