# Any chance of someone helpin me with a problem with my pants shooting game?

**URL:** https://forum.kirupa.com/t/any-chance-of-someone-helpin-me-with-a-problem-with-my-pants-shooting-game/287987
**Category:** flash
**Created:** [May 8, 2009, 10:28pm UTC](https://forum.kirupa.com/t/any-chance-of-someone-helpin-me-with-a-problem-with-my-pants-shooting-game/287987 "2009-05-08T22:28:13Z")
**Posts on this page:** 1
**Page:** 1

<div class="post-metadata">

### Author: ![Judda](https://avatars.discourse-cdn.com/v4/letter/j/a5b964/32.png) [@Judda](https://forum.kirupa.com/u/Judda)
#### Post date: [May 8, 2009, 10:28pm UTC](https://forum.kirupa.com/t/any-chance-of-someone-helpin-me-with-a-problem-with-my-pants-shooting-game/287987/1 "2009-05-08T22:28:13Z")

</div>

Cheers for taking time to look at this.  
Im needing to get this little game finished in a week or so and having problems with a working energy bar which decreases when a bullys face gets to big before you shoot it. The energy bar is a simple movie tween consisting of 3 frames for the decreasing energy.

if I take out these parts of the code my game works ok:  
var score:int;  
var energy:int; (and all the sections which work with these :int; 's.)

This is posing a problem becuase I need an energy bar for the game to have a win lose ending.

HERE IS THE CODE

var monstersInGame:uint;  
var monsterMaker:Timer;  
var container\_mc:MovieClip;  
var cursor:MovieClip;  
var score:int;  
var energy:int;

function initializeGame(): void  
{  
monstersInGame = 15;  
monsterMaker = new Timer (1000, monstersInGame);  
container\_mc = new MovieClip();  
addChild(container\_mc);

```
monsterMaker.addEventListener(TimerEvent.TIMER, createMonsters);
monsterMaker.start();

cursor = new Cursor();
addChild(cursor);
cursor.enabled = false
Mouse.hide();
stage.addEventListener(MouseEvent.MOUSE_MOVE, dragCursor);

score = 0;
energy = energy_mc.totalFrames;
energy_mc.gotoAndStop(energy);

```

}

function dragCursor(event:MouseEvent):void  
{  
cursor.x = this.mouseX;  
cursor.y = this.mouseY;  
}

function createMonsters(event:TimerEvent):void  
{  
var monster:MovieClip;  
monster = new bullyface();  
monster.x = Math.random() \* stage.stageWidth;  
monster.y = Math.random() \* stage.stageHeight;  
container\_mc.addChild(monster);  
}

function increaseScore():void  
{  
score++;  
if(score \>= monstersInGame)  
{  
monsterMaker.stop();  
trace(“you beat that bully good!”);  
}  
}

function decreseEnergy():void  
{  
energy --;  
if(energy \<=0)  
{  
monsterMaker.stop();  
trace(“you lose!”)  
}  
else  
{  
energy\_mc.gotoAndStop(energy);  
}  
}

initializeGame();

THESE ARE THE ERRORS

Scene1: Layer’Actions’ Frame1, Line25 - 1120: Access of undefined property energy\_mc. energy = energy\_mc.totalFrames;  
Scene1: Layer’Actions’ Frame1, Line 26 - 1120: Access of undefined property energy\_mc. energy\_mc.gotoAndStop(energy);  
Scene1: Layer’Actions’ Frame1, Line 64 - 1120: Access of undefined property energy\_mc. energy\_mc.gotoAndStop(energy);

I appreciate any help with this matter, Thanks again for taking time to look over this.

Leon
