# Bullet bar

**URL:** <https://forum.kirupa.com/t/bullet-bar/118108>\
**Category:** Uncategorized\
**Created:** [August 2, 2004, 8:03pm UTC](https://forum.kirupa.com/t/bullet-bar/118108 "2004-08-02T20:03:33Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![yhack](https://avatars.discourse-cdn.com/v4/letter/y/3da27b/32.png) [@yhack](https://forum.kirupa.com/u/yhack)\
**Post date:** [August 2, 2004, 8:03pm UTC](https://forum.kirupa.com/t/bullet-bar/118108/1 "2004-08-02T20:03:33Z")

</div>

Hi i have a bar of 6 bullets

1 2 3 4 5 6

when there all gone it ses reload

ive got all the frames worked out and everything but i need help with actionscript…

I thought when u click (shoot) on a enemy it cud set a variable -1.  
when its at 6 “\_root.bullets” frame is 7, when at 5 frame it 6 etc.

then when u press space it sets the variable to 6 which would make the frame 7

if you could help me with any or all of this i would be grateful

thx in advance,  
yhack

---

<div class="post-metadata">

**Author:** ![macneilslt](https://avatars.discourse-cdn.com/v4/letter/m/aeb1de/32.png) [@macneilslt](https://forum.kirupa.com/u/macneilslt)\
**Post date:** [August 3, 2004, 12:05am UTC](https://forum.kirupa.com/t/bullet-bar/118108/2 "2004-08-03T00:05:08Z")

</div>

okay, assuming you have 7 frames in MC with an instance of bullets…  
where the 7th frame has 6 bullets,  
6th frames has 5 bullets,  
5th frame has 4 bullets,  
4th frame has 3 bullets, 3rd frame has 2 bullets,  
2nd frame has one bullet  
and the first frame says reload…

put this AS on the main timeLine first keyframe:

```auto

numBullets = 6;
bullets.gotoAndStop(7);
this.onMouseDown = function() {
	if (numBullets>=1) {
		numBullets -= 1;
		bullets.gotoAndStop(numBullets+1);
	}
};
Key.addListener(this);
this.onKeyDown = function() {
	if(key.isDown(key.SPACE)) {
		numBullets = 6;
		bullets.gotoAndStop(7);
	}
};

```

That will do it…

---

<div class="post-metadata">

**Author:** ![yhack](https://avatars.discourse-cdn.com/v4/letter/y/3da27b/32.png) [@yhack](https://forum.kirupa.com/u/yhack)\
**Post date:** [August 3, 2004, 10:14am UTC](https://forum.kirupa.com/t/bullet-bar/118108/3 "2004-08-03T10:14:00Z")

</div>

thx so much!!!
