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

New Here ,
May 30, 2021 May 30, 2021

Copy link to clipboard

Copied

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
		}
	}
}
TOPICS
ActionScript , Code , Error

Views

162

Likes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
May 30, 2021 May 30, 2021

Copy link to clipboard

Copied

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

Likes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
May 30, 2021 May 30, 2021

Copy link to clipboard

Copied

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);
        }
    }
}

Likes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Adobe Community Professional ,
May 31, 2021 May 31, 2021

Copy link to clipboard

Copied

LATEST

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

Likes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines