Triple
07-12-2012, 04:48 PM
ACTIONSCRIPT 3
Hey, I'm having trouble with a health bar in my game. I'm a total beginner at Flash, and when I saw that, I mean I have almost no idea what I'm doing.
I started off by making a movie clip. Inside, I made a 101 frame (I included 0%) tween. Then I made a layer for actions in the movie clip, I wrote this in the actionscript:
var health:Number = 0;
if(health == 0)
{
gotoAndStop("1")
}
if(health == 1)
{
gotoAndStop("2")
}
and on...
Anyway, I quickly realized that the health variable will not work outside of the movie clip, like if I were to make a button and did the actionscript like:
var health:Number = 0;
fortyfiveup_btn.addEventListener(MouseEvent.CLICK, fortyfiveupClick);
function fortyfiveupClick(event:MouseEvent):void{
health = health-5
}
it would not take the health out from health bar. Can you please help me out in the simplest way possible?
:confused:
Hey, I'm having trouble with a health bar in my game. I'm a total beginner at Flash, and when I saw that, I mean I have almost no idea what I'm doing.
I started off by making a movie clip. Inside, I made a 101 frame (I included 0%) tween. Then I made a layer for actions in the movie clip, I wrote this in the actionscript:
var health:Number = 0;
if(health == 0)
{
gotoAndStop("1")
}
if(health == 1)
{
gotoAndStop("2")
}
and on...
Anyway, I quickly realized that the health variable will not work outside of the movie clip, like if I were to make a button and did the actionscript like:
var health:Number = 0;
fortyfiveup_btn.addEventListener(MouseEvent.CLICK, fortyfiveupClick);
function fortyfiveupClick(event:MouseEvent):void{
health = health-5
}
it would not take the health out from health bar. Can you please help me out in the simplest way possible?
:confused: