This time i wanted to make a nice progress bar for the preloader i've made. First of all, the usual check of Google. Plenty of hits, mostly for AS2 - a few for AS3 but nothing that takes my fancy. I did see a nice turning "barbershop pole" stripe bar, which i started out aiming for but before i'd written much code i figured a nice thing to do would be to simulate the nice glossy progress bars seen in windows vista. If it hasn't got anything else right, it has nice progress bars. Even though they still run on "microsoft time" and hardly give you a good indication of how long something is going to take, they do stand out and look the business.
They have nice shadows and highlights, with a good gloss colour. It took me a little while to figure out how to "draw" them in AS3, but i think my final version looks pretty good (click on the picture to see it in action!)
It's drawn using a rounded rect, and a line rect, and a few gradient filled rectangles on top of eachother (with alphas). It's quiet small and fast and easy to re-use or change the colour of the bar. I'll be using this in my next blog which will be a simple preloader (with a fancy looking vista style progress loader bar). Hopefully it makes a change from the thin faded lines and the standard boring rectangles that mochiads use and looks nice while people are waiting for something to load! You could also use this to make glossy buttons by adding text - which would look nice for a change instead of the standard looking ones, and you don't have to pre draw them either. Remember that this is a bit slower when updating than if it was pre rendered in something like photoshop, but it's unlikely to slow anything down.
One thing i fell over while making this class was a slow down the further it got. It had something todo with me forgetting to add a "graphics.clear" to the start of the Redraw() function. I guess it was piling up graphics, but i didn't realise that causes a slowdown - i thought you could just overwrite the previous graphics with the new ones and all would be fine, so i thought i was saying time by not calling clear and just drawing on top. I guess when i have sometime i'll look into that - unless someone already knows the answer (it's probably something really obvious - don't forget i'm still learning AS3 too!).
Get the ProgressBar.as or the FlashDevelop project. To use the progress bar, import the class
import com.adventuresinactionscript.ui.ProgressBar;
then create a progress bar with the following
var progressBar:ProgressBar = new ProgressBar(x,y,width,height);
addChild(progressBar);
and update it with
progressBar.Update(progress);
Remember that you need to call Update() atleast once to draw the bar.

Mon, 03/30/2009 - 17:55
Nice work. I like the rounded corners a bit higher than their default (2) though.
Sun, 03/29/2009 - 03:44
Okay, Anonymous (who-ever you are). If the actionscript panel is greyed out, that means you have selected a wrong element. You can put actionscript on MCs, Graphics, Buttons and just timeline keyframes. If it is greyed out, you probably have a grouped object or a broken one.
Hope you can get it working.
Tue, 11/18/2008 - 16:19
if you are using AS3, the code you need is right there at the bottom of the post. You just put it in your main timeline as. You have to download the .as file first and import the class as indicated above. If you don't know what this means than you are not ready to be coding in as3 and you need to review the very basics. It is different enough from as2 as to be almost a completely different language. You do not put actions on objects at all in as3 which is waaaay better than as2.
Tue, 11/18/2008 - 12:03
Are you using CS3? I think your not allowed to add actionscript to a movieclip anymore, i believe you have to make a keyframe to put the code in. I don't use CS3, so i'm not sure how easy it is to use my components like that - if anyone else is interested i could have a look and put a tutorial up - let me know how you get on!
Tue, 11/18/2008 - 09:20
when i try to put the actions into AS3, it says it wont take it 'current selection cannot have actions aplied it'. is this normal? i cant do anything with AS3, cos the actions just dont go in! i cant use AS2 for this either cos my progressbar dosn't take actions. i just cant even access the action pane, the word 'actions' is grey instead of black, meaning i cant click on it.
Post new comment