0
votes
this.onEnterFrame = function()
{
        if(Key.isDown(Key.RIGHT))
        {
                asdf._x += 10;
        }else if (Key.isDown(Key.LEFT))
        {       
                asdf._x -= 10;
        }else if (Key.isDown(Key.UP))
        {
                asdf._y -= 10;
        }else if (Key.isDown(Key.DOWN))
        {
                asdf._y += 10;
        }
}
var i = 0;
this.onEnterFrame = function()
{
        else if (Key.isDown(Key.DOWN))
    {            
        asdf._y += 5;
            }
            if (Key.isDown(Key.SPACE))
            {
                i++;
                _root.attachMovie("Bullet", "Bullet" + i,_root.getNextHighestDepth());
                _root["Bullet" + i]._x = asdf._x + 3;
                _root["Bullet" + i]._y = asdf._y
            }
}

Whenever i try to run this, i get the following error: "Scene=Scene 1, layer=Layer 1, frame=1, Line 21 'else' encountered without matching 'if'"

1
You have an else without an if as the first line of the onEnterFrame function - Maerlyn

1 Answers

2
votes
var i = 0;
this.onEnterFrame = function()
{
    else if (Key.isDown(Key.DOWN))
    {            

You can't start a function with else without a corresponding if. What you mean may be just plain;

var i = 0;
this.onEnterFrame = function()
{
    if (Key.isDown(Key.DOWN))
    {