AS: Main , it's better then sex with a n00b!
I'm aware this is not the only way, there's also the precent and xscale thing, feel free to post it if you wanna
This tutorial requires you knowing Variables (ignore our funny replies in that post) and understanding Symbols ... this will use the movieclip's ._x property and ._y property
if you really want to tune it corrently (have it grow EXACTLY as much as you need it each time, you will also need to understand and use Linear Increasment which also somewhat explains the concept.
First of all we start by defining a new movieclip, call it however you want and inside it draw a square or something similar (doesn't matter if it's a square or a rectangle)
Let's start by giving the movieclip some actions (by opening the actions window and clicking the movieclip), we start by declaring WHEN the actions happen, inside movieclips we always have to do this, I want the actions to happen each frame enter (meaning 1 / 12 per second for default) the code for this is
this does nothing yet, but it's the handler itself, in flash, a handler means something that triggers everytime something else happens, in this case that something is the frame increasing (works even if you used stop()).
Now a movieclip has a _width property, this specifies it's width on the stage, so all we have to do, is change it's width accordingly, I'll presume your score/health variable is _root.score , the name is irrelevant really... Let's say the score is around between 1 and 100 (this part is explained a lot better in AS: Linear Increasment), now presuming we want the bar's width to move between 1 and 100 and the score is between 1 and 100 all we have to do is type
In the bar's actions, we want this to happen on every "enterFrame", so now our code is:
Congrats, we have created a working bar... currently it's aligned to the center, but you can also align it to the right by adding this._x=baseX+this._width/2 (assuming you declared baseX in the 'load; part, which if i'm not mistaken my friend toast explained in AS variables. Same works for aligning it to the left.
Ask any questions! post any tutorials! (related)