PDA

View Full Version : Simple but effective display bar



Dhryn
December 19th, 2006, 06:54 PM
If you are wanting to create a display bar for a game for a preloader, then this might help you out.

To explain a little better what is happening I have used long varialble names which probably wouldnt be used in a flash application.

-----------------
40336
-----------------

Downloading and opening the source file will help you to understand what I am saying below.


countTotal = 267;
countProgress = 125;
greenBarTotalLength = 200;
greenBar.bar._width = ((countProgress/countTotal)*greenBarTotalLength);


Using:
countTotal for the maximum mark, e.g. full health.
countProgress for the current mark e.g. current health.
greenBarTotalLength is the size of your display bar.
greenBar is the display bar, bar is the moving part of the bar.

This bar will work with any length, and with any countProgress.

-----------
Explanation
-----------
Taking the bar to be display a percentage, which if you have taken a test, is worked out as, your mark divided by the total marks multiplied by 100.

Then to work out the extra part to be added, we take the length of the bar, divided it by a hundred and then multiplied the first part by this.

But because multiplication and divition is commutative when done correctly we can remove the mutliply by 100 from the first part and replace it with the total length.

200 / 100 * 100 = 200

Hope this helps. If you havent understood what I have said then please post here and I, or some one else, will try and help you

bombsledder
December 19th, 2006, 09:23 PM
thanks for sharing but shouldnt this be under, sources/expirements

Dhryn
December 19th, 2006, 09:29 PM
no idea, didnt know where to put it, I have used it for games os I put it here, plus I have seen threads for this kinda thing here.

bombsledder
December 19th, 2006, 09:30 PM
ya its a good idea to post, im not sure if its breaking the rules but i know they have a dedicated section to posting source, and showing off your expirements im sure it will help people out though

Dhryn
December 19th, 2006, 09:34 PM
If I do something like this again, then I should find the correct area to post it then, I shouldnt just post it to an area that I think it is relevant?

bombsledder
December 19th, 2006, 10:09 PM
well it is relevant i guess, im not a mod... so i don't know how strict they are but they would probably just move into sources/ expirements

nathan99
December 20th, 2006, 06:10 AM
I'm pretty sure this forum would be an appropriate location. However, if you wanted as much views as possible, I would either put it into a busier forum, or source/experiment, where people woul LOOK for this kind of stuff.