# Else if function not working with While function why?

**URL:** <https://forum.kirupa.com/t/else-if-function-not-working-with-while-function-why/119732>\
**Category:** Uncategorized\
**Created:** [August 17, 2004, 6:22pm UTC](https://forum.kirupa.com/t/else-if-function-not-working-with-while-function-why/119732 "2004-08-17T18:22:29Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![phree\_style](https://avatars.discourse-cdn.com/v4/letter/p/c77e96/32.png) [@phree\_style](https://forum.kirupa.com/u/phree_style)\
**Post date:** [August 17, 2004, 6:22pm UTC](https://forum.kirupa.com/t/else-if-function-not-working-with-while-function-why/119732/1 "2004-08-17T18:22:29Z")

</div>

I got a code (

```auto
onClipEvent (enterFrame) {
 if (_root.chatbox == "buy") { while (_root.shop == "What would you like to do?") {
   _root.shop = "Yes, Ok then.";
   _root.items._visible = 1;
} else if (_root.chatbox == "sell") {
_root.shop = "Ok. I see you have chosen sell.";
_root.items._visible = 0;
  }
 }
}

```

)

the Else if function doesnt seem to work well with while function.  
When i got rid of the while function it worked.

Any one know why this is happening?

---

<div class="post-metadata">

**Author:** ![phree\_style](https://avatars.discourse-cdn.com/v4/letter/p/c77e96/32.png) [@phree\_style](https://forum.kirupa.com/u/phree_style)\
**Post date:** [August 17, 2004, 6:57pm UTC](https://forum.kirupa.com/t/else-if-function-not-working-with-while-function-why/119732/2 "2004-08-17T18:57:44Z")

</div>

NVM, got it to work.

---

<div class="post-metadata">

**Author:** ![Sandman9](https://avatars.discourse-cdn.com/v4/letter/s/6a8cbe/32.png) [@Sandman9](https://forum.kirupa.com/u/Sandman9)\
**Post date:** [August 17, 2004, 6:58pm UTC](https://forum.kirupa.com/t/else-if-function-not-working-with-while-function-why/119732/3 "2004-08-17T18:58:12Z")

</div>

Couldn’t you just say

```auto

onClipEvent (enterFrame) {
 if (_root.chatbox == "buy" && _root.shop == "What would you like to do?") {
   _root.shop = "Yes, Ok then.";
   _root.items._visible = 1;
}

```

Sandman9

---

<div class="post-metadata">

**Author:** ![phree\_style](https://avatars.discourse-cdn.com/v4/letter/p/c77e96/32.png) [@phree\_style](https://forum.kirupa.com/u/phree_style)\
**Post date:** [August 17, 2004, 7:02pm UTC](https://forum.kirupa.com/t/else-if-function-not-working-with-while-function-why/119732/4 "2004-08-17T19:02:09Z")

</div>

ok that works better.
