Skip to main content
Participant
May 31, 2021
Question

Scene 1, Layer 'Actions', Frame 1, 1084: Syntax error: expecting rightparen before colon.

  • May 31, 2021
  • 3 replies
  • 467 views

I'm new to Animate and I've got this code and this error that keeps repeating.

 

Scene 1, Layer 'Actions', Frame 1, Line 78, Column 20	1084: Syntax error: expecting rightparen before colon.

 This is the code I have

function timing(evt:TimerEvent):void
{
	timeStep += 1; //increment counter
	if (run) //only if run = true is shift key has been pressed
	{
		moveCharacter(evt:KeyboardEvent)
		{
			timeStep = 0; //reset the counter
		}
	}
	else if (timeStep == 2)
	{
		moveCharacter(evt:KeyboardEvent)
		{
			timeStep = 0; //reset the counter
		}
	}
}
This topic has been closed for replies.

3 replies

JoãoCésar17023019
Community Expert
Community Expert
May 31, 2021

Hi.

 

There are some confusing things.

 

- The timing function expects a TimerEvent object, but you're trying to call the moveCharacter function that expects a KeyboardEvent object.

- The moveCharacter function is being called(?) incorrectly. It should be moveCharacter(evt); only, without the curly braces and the event type. But, anyway, there's no way - or at least doesn't make sense - to expect a KeyboardEvent inside of a TimerEvent handler function.

 

Can you verify these two points?

 

Regards,

JC

Participant
May 31, 2021

This is the moveCharacter function

 

function moveCharacter(evt:KeyboardEvent):void
{
    if (evt.keyCode == Keyboard.RIGHT)
    {
        eggHead.scaleX = 1; //flip right
        eggHead.x += 10;
        
        //cycle through frames
        if (eggHead.currentFrame == 9)
        {
             eggHead.gotoAndStop(2);
        }
        else
        {
            eggHead.gotoAndStop(eggHead.currentFrame+1);
        }
    }
        
    if (evt.keyCode == Keyboard.LEFT)
    {
        eggHead.scaleX = -1; //flip left
        eggHead.x -= 10;
        
        //cycle through frames
        if (eggHead.currentFrame == 9)
        {
            eggHead.gotoAndStop(2);
        }
        else
        {
            eggHead.gotoAndStop(eggHead.currentFrame+1);
        }
    }
}
Participant
May 31, 2021

I forgot to say, the error is on Line 78 and 85, which is the moveCharacter(evt:KeyboardEvent) line.