This content has been marked as final.
Show 2 replies
-
1. Re: Drawing with ActionScript3.0(Sprite) in Flash CS4
Ross Ritchey Oct 6, 2009 5:02 AM (in response to Me2LoveIt2)I believe you are looking for the clear() function. Note, I also moved the bar variable declaration out of the function so that you don't reinitialize it unnecessarily, as well as the addChild so you only add the bar to the stage once.
var hp:Number = 100 //note this is not the complete code just the piece I want to focus on
var bar:Sprite = new Sprite();
addChild(bar);
this.addEventListener(Event.ENTER_FRAME, hpBar); function hpBar(event:Event):void{ if(character_mc.hitTestObject(hp_mc)){ hp+=1 }else if(character_mc.hitTestObject(dmg_mc)){ hp-=1 }
bar.graphics.clear();//
bar.graphics.beginFill(0x33ff00); bar.graphics.drawRect(50, 50, hp, 15) bar.graphics.endFill(); }; -
2. Re: Drawing with ActionScript3.0(Sprite) in Flash CS4
Me2LoveIt2 Oct 6, 2009 5:34 AM (in response to Ross Ritchey)Thank you so much this is exactly what I needed.

