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
}
}
}
Copy link to clipboard
Copied
I forgot to say, the error is on Line 78 and 85, which is the moveCharacter(evt:KeyboardEvent) line.
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);
}
}
}
Copy link to clipboard
Copied
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
Find more inspiration, events, and resources on the new Adobe Community
Explore Now