# \[AS2\]Else If Problem

**URL:** <https://forum.kirupa.com/t/as2-else-if-problem/302384>\
**Category:** programming\
**Created:** [December 29, 2009, 11:25am UTC](https://forum.kirupa.com/t/as2-else-if-problem/302384 "2009-12-29T11:25:12Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![Jephz](https://avatars.discourse-cdn.com/v4/letter/j/58956e/32.png) [@Jephz](https://forum.kirupa.com/u/Jephz)\
**Post date:** [December 29, 2009, 11:25am UTC](https://forum.kirupa.com/t/as2-else-if-problem/302384/1 "2009-12-29T11:25:12Z")

</div>

Hi everyone, its been awhile. I’m still working on the battle engine, and I’m up to the phase where I’m programming a in-detailed enemy AI(its turn-based btw).

I’ll cut straight to the chase. For some out-of-the-whack reason, “else if” doesn’t work, but “else” does.

Heres my current code:

```auto
               
 if(_root.enemymana == 20) {
                enemyAttackList = [];
                enemyAttackList.push([COLOR=SeaGreen]"Laser Blast","Arrow Shot","Focus","Normal"[/COLOR]);
[LEFT] currentAttack = enemyAttackList[1]
[/LEFT]
                } else { [COLOR=Gray]//if (_root.enemymana > 20) {[/COLOR]
                enemyAttackList = [];
                enemyAttackList.push([COLOR=SeaGreen]"Normal"[/COLOR]);
                currentAttack = enemyAttackList[0]
                }
            }

```

Now this works, but when I implement “else if”, it won’t cycle through it. I’ve tried taking out “else” and putting “if” instead, but it won’t budge either.

Any bright ideas?

-Jephz
