Wdoug
Wdoug

Reputation: 27

ActionScript 3, 1084: Syntax error: expecting rightparen before dot

Can someone help with this please. I'm trying to do a simple coding tutorial and make a guy walk around the screen but I keep running into the same error

Scene 1, Layer 'Actions', Frame 1, Line 11, Column 33   1084: Syntax error: 
expecting rightparen before dot.

This is the code and I can't seem to find an explanation for what to do. I've followed the tutorial word by word

import flash.events.KeyboardEvent;
import flash.ui.Keyboard;
import flash.display.MovieClip;
import flash.events.Event;
import flash.display.Stage;

heroMc.gotoAndStop("FrontBackStill");

stage.addEventListener(KeyboardEvent.KEY_DOWN, keyDownHandler);

function keyDownHandler(keyEvent.KeyboardEvent):void
{
    if(keyEvent.keyCode==Keyboard.RIGHT)
    {
        trace("You pressed right!");
    }
}

Upvotes: 0

Views: 436

Answers (1)

Glycerine
Glycerine

Reputation: 7347

In the keyDownHandler the parameters should read:

function keyDownHandler(keyEvent:KeyboardEvent):void
{
    // ...
}

Noting the colon not a period after the keyEvent.

This is because you're receiving an event object - of which you're naming keyEvent. This is type (:) KeyboardEvent.

Upvotes: 2

Related Questions