# Flash as2 Help with my Actionscript File

**URL:** <https://forum.kirupa.com/t/flash-as2-help-with-my-actionscript-file/331755>\
**Category:** flash\
**Created:** [October 13, 2013, 7:39pm UTC](https://forum.kirupa.com/t/flash-as2-help-with-my-actionscript-file/331755 "2013-10-13T19:39:53Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![Jason\_Scholz](https://avatars.discourse-cdn.com/v4/letter/j/53a042/32.png) [@Jason\_Scholz](https://forum.kirupa.com/u/Jason_Scholz)\
**Post date:** [October 13, 2013, 7:39pm UTC](https://forum.kirupa.com/t/flash-as2-help-with-my-actionscript-file/331755/1 "2013-10-13T19:39:53Z")

</div>

Cannot figure out WHY this is not working. I created a Actionscript File called Hero.as. I have a movieclip with no instance name called Hero. Hero is set to export for actionscript. Inside of my Hero movieclip, on frame two is my animation movieclip.  
So what I am doing is when the key RIGHT is pressed, the character moves right! This is REALLY easy if I am NOT using an Actionscript file. However, using the same code inside of my actionscript file, I cannot get the animation to play. The character moves right, but no animation. Here is the code:

class Hero extends MovieClip  
{  
var velocity;

```
function onLoad()
{
    velocity = 10;
}

function onEnterFrame()
{
    if(Key.isDown(Key.RIGHT))
    {
        _root.hero.gotoAndPlay(2);
        _x = _x + velocity;            
    }
}

```

}
