PDA

View Full Version : [AS3] Hp bar not working


ojebus
06-29-2009, 04:13 PM
I'm trying not to come here every time my game isnt working but there are no sites online that are for as3 that deal with the things I'm having issues with. My hp bar isn't working I dont know how to code it right I just took what they had for as2 and tried to change it into as3 material by adapting it a little.
It comes up with this error
ReferenceError: Error #1069: Property hp not found on flash.display.Stage and there is no default value.at ga_fla::hp_12/frame1()

here is my file:
www.nibbletandnathan.com/curseyou/ga.fla

vdLoo88
06-29-2009, 04:35 PM
hey,

try placing your hitTest, "if (bat.hitTestObject(mcMain))"

inside the ENTER_FRAME function "moveChar" this should point you in the right direction...

Also, scaleX is not a function:

hp.scaleX -=5 (); //wrong

hp.scaleX -= 5; //right

Try smaller values like .2 or .1 instead of 5.

There are more efficient ways of implementing hp bars! do some research!

Cheers.

ojebus
06-29-2009, 05:02 PM
I dont know what was is efficent I have looked online for tutorials on this but I cant find any for as3. I guess I'll have to buy a book.
I did what you told me to but for some reason the hpbar is growing instead of shrinking.

bluemagica
06-29-2009, 08:46 PM
here's a simple class i wrote! try reading the included as and fla file to understand it...

http://blog.bluemagica.com/?p=11