# Platformer; Time-based animation states - please advise me!

**URL:** <https://forum.kirupa.com/t/platformer-time-based-animation-states-please-advise-me/315258>\
**Category:** programming\
**Created:** [October 21, 2010, 6:40am UTC](https://forum.kirupa.com/t/platformer-time-based-animation-states-please-advise-me/315258 "2010-10-21T06:40:53Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![stillwired](https://avatars.discourse-cdn.com/v4/letter/s/46a35a/32.png) [@stillwired](https://forum.kirupa.com/u/stillwired)\
**Post date:** [October 21, 2010, 6:40am UTC](https://forum.kirupa.com/t/platformer-time-based-animation-states-please-advise-me/315258/1 "2010-10-21T06:40:53Z")

</div>

I’ve been working on my first game with the help of a book (AS3 Game Programming University for those familiar), and I’ve been stuck on this issue for a while now. I’ve tried searching high and low for the answer but I’m at a loss.

Basically I worked through my book’s chapter on platformers and now I’m trying to make my own improvements to it, specifically the character’s jump and stand animations. It’s a little trickier for me because it’s time-based animation and I have one mc for the hero with the frames labeled for each animation state (walk, jump, etc.), but when I tried to figure out how to add the necessary code to play a jump sequence instead of a single frame jump it gets hairy. The character actually does the jump animation sometimes but sometimes he just jumps and stays in the stand position…

I don’t have any compiler errors but I get the #1010 error when I run the movie, which I found out has something to do with referencing an array or having an incorrect instance name?

**TypeError: Error #1010: A term is undefined and has no properties.  
at PlatformGame/moveCharacter()[D:\PlatformGame.as:310]  
at PlatformGame/moveEnemies()[D:\PlatformGame.as:179]  
at PlatformGame/gameLoop()[D:\PlatformGame.as:168]**

I checked and I believe the array I set up to hold the frame numbers that belong to the jump animation is correct, since it’s just like the working walkAnimation array, but like I said I’m at a loss.

```
        hero.walkAnimation=new Array(2,3,4,5,6,7,8,9,10,11,12);
        hero.jumpAnimation=new Array(13,14,15,16,17,18,19,20,21,22,23);

```

It must have something to do with me writing the code for the jump animation incorrectly, so here’s the relevant code from the moveCharacter function, with my suspicious code in blue:

```
        // set animation state
        if (char.inAir) { newAnimState = "jump";}
                    
        char.animstate=newAnimState;

        // move along walk cycle
        if (char.animstate=="walk") {
            char.animstep+=timeDiff/60;
            if (char.animstep&gt;char.walkAnimation.length) {
                char.animstep=1;
            }
            char.mc.gotoAndStop(char.walkAnimation[Math.floor(char.animstep)]);

            // not walking, show stand or jump state
        } else {
            char.mc.gotoAndStop(char.animstate);

```

[COLOR=RoyalBlue] {  
if (char.animstate==“jump”) {  
char.animstep += timeDiff / 60;  
if (char.animstep\>char.jumpAnimation.length) {  
char.animstep=13;  
}  
char.mc.gotoAndPlay(char.jumpAnimation[Math.floor(char.animstep)]);

```
            }
        }

```

[/COLOR]  
// changed direction  
if (newDirection!=char.direction) {  
char.direction=newDirection;  
char.mc.scaleX=char.direction;  
}

```
        }
        
    }

```

I’d really appreciate it if someone could school me on this, I pretty much understand how time-based animation works, but I don’t have a lot of experience yet. Help me out please, I’m beggin’ ya!
