# Condition still true so statement repeats itself

**URL:** <https://forum.kirupa.com/t/condition-still-true-so-statement-repeats-itself/265706>\
**Category:** flash\
**Created:** [July 11, 2008, 2:51pm UTC](https://forum.kirupa.com/t/condition-still-true-so-statement-repeats-itself/265706 "2008-07-11T14:51:39Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![Liam19](https://avatars.discourse-cdn.com/v4/letter/l/22d042/32.png) [@Liam19](https://forum.kirupa.com/u/Liam19)\
**Post date:** [July 11, 2008, 2:51pm UTC](https://forum.kirupa.com/t/condition-still-true-so-statement-repeats-itself/265706/1 "2008-07-11T14:51:39Z")

</div>

Hey I’m trying to debug a game I’ve been developing over the past few months.  
Its about manoeuvering a bubble through the level without touching anything.  
Quite similar to ‘Soap Bubble’ for those of you who have played it.

So here’s my problem, I want the bubble to play a “bursting” animation when it touches the wall using this code:

if (bubble.hitTest(wall)){  
\_root.bubble.gotoAndPlay(“bursting”);  
}

However, as the condition is still true after one or two frames it will begin the animation again and again.

How can I fix this so that it will only play once even if it is still touching the wall?

Thanks

---

<div class="post-metadata">

**Author:** ![senocular](https://yyz1.discourse-cdn.com/flex011/user_avatar/forum.kirupa.com/senocular/32/7217_2.png) [@senocular](https://forum.kirupa.com/u/senocular)\
**Post date:** [July 11, 2008, 2:58pm UTC](https://forum.kirupa.com/t/condition-still-true-so-statement-repeats-itself/265706/2 "2008-07-11T14:58:34Z")

</div>

That depends on how you’re running that code. You’ll just need to stop running it once it hits the first time.

---

<div class="post-metadata">

**Author:** ![randomagain](https://avatars.discourse-cdn.com/v4/letter/r/35a633/32.png) [@randomagain](https://forum.kirupa.com/u/randomagain)\
**Post date:** [July 11, 2008, 3:01pm UTC](https://forum.kirupa.com/t/condition-still-true-so-statement-repeats-itself/265706/3 "2008-07-11T15:01:25Z")

</div>

delete this.onEnterFrame lol 😛

---

<div class="post-metadata">

**Author:** ![Liam19](https://avatars.discourse-cdn.com/v4/letter/l/22d042/32.png) [@Liam19](https://forum.kirupa.com/u/Liam19)\
**Post date:** [July 11, 2008, 3:12pm UTC](https://forum.kirupa.com/t/condition-still-true-so-statement-repeats-itself/265706/4 "2008-07-11T15:12:42Z")

</div>

I’m not exactly sure how I’m running it, (I’m not exactly a programmer)  
If it’s any help it’s under this:

\_root.onEnterFrame = function ()  
{

And I don’t have this.onEnterFrame in the file at all.

---

<div class="post-metadata">

**Author:** ![glosrfc](https://yyz1.discourse-cdn.com/flex011/user_avatar/forum.kirupa.com/glosrfc/32/8334_2.png) [@glosrfc](https://forum.kirupa.com/u/glosrfc)\
**Post date:** [July 11, 2008, 3:21pm UTC](https://forum.kirupa.com/t/condition-still-true-so-statement-repeats-itself/265706/5 "2008-07-11T15:21:20Z")

</div>

You need to assign an additional variable against which to check your if statement, e.g.

```auto

burst = false;
if (!burst && _root.bubble.hitTest(wall)) {
	burst = true;
	_root.bubble.gotoAndPlay("bursting");
}

```

---

<div class="post-metadata">

**Author:** ![Liam19](https://avatars.discourse-cdn.com/v4/letter/l/22d042/32.png) [@Liam19](https://forum.kirupa.com/u/Liam19)\
**Post date:** [July 11, 2008, 3:35pm UTC](https://forum.kirupa.com/t/condition-still-true-so-statement-repeats-itself/265706/6 "2008-07-11T15:35:04Z")

</div>

fan bloody tastic  
your a star

Cheers dude
