# Counter problem

**URL:** <https://forum.kirupa.com/t/counter-problem/256734>\
**Category:** Uncategorized\
**Created:** [April 6, 2008, 6:11pm UTC](https://forum.kirupa.com/t/counter-problem/256734 "2008-04-06T18:11:18Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![insane\_soni](https://avatars.discourse-cdn.com/v4/letter/i/e19b73/32.png) [@insane\_soni](https://forum.kirupa.com/u/insane_soni)\
**Post date:** [April 6, 2008, 6:11pm UTC](https://forum.kirupa.com/t/counter-problem/256734/1 "2008-04-06T18:11:18Z")

</div>

please help me in this small bit…

In the 1st frame I’m attaching ball mc, and inside that movieclip I’ve kept 1 counter,

which runs till second count… n at the second count am removing another mc… as follows :-

```auto

//on frame 1
newMC = this.attachMovie("ball1","ball1"+count,count++);

//inside the above ball movieclip

var hit=0;

onEnterFrame = function()
if(this.hitTest(this._parent.car_mc))
            {               
               hit++;
               trace("hit"+" "+hit);
               trace("HIT the car!");
               if(hit<3){
                  
                  if(hit==1){
                     _root.score +=100;
                  }
                  if(hit==2)
                  {
                     _parent.car1_mc.gotoAndStop(3);
                     _root.score+=100;
                     
                  }
               }

```

my problem is every time it enters the onEnterFrame function the counter resets

to 0 again…

I want that var hit should reset to its previous value n thats 1…then next time

when it will enter into onEnterframe it should be 2…

so how to do this?  
thank you
