Copy link to clipboard
Copied
So, this is my code.
```````````
import flash.events.KeyboardEvent;
stage.addEventListener(KeyboardEvent.KEY_DOWN,moveClip);
function moveClip(event:KeyboardEvent):void
{
if(event.keyCode == 40)
{
mcSquare1.y += 10;
}
}
stage.addEventListener(KeyboardEvent.KEY_UP,moveClip2);
function moveClip2(event:KeyboardEvent):void
{
if(event.keyCode == 38)
{
mcSquare1.y -= 10;
}
}
stage.addEventListener(KeyboardEvent.KEY_UP,moveClip3);
function moveClip3(event:KeyboardEvent):void
{
if(event.keyCode == 37)
{
mcSquare1.x -= 10;
}
}
stage.addEventListener(KeyboardEvent.KEY_UP,moveClip4);
function moveClip4(event:KeyboardEvent):void
{
if(event.keyCode == 39)
{
mcSquare1.x += 10;
}
}
stage.addEventListener(KeyboardEvent.KEY_UP,moveClip5);
function moveClip5(event:KeyboardEvent):void
{
if(event.keyCode == 16)
{
mcSquare1.rotation += 315;
}
}
var mcScore == 0;
if (mcSquare1.hitTest(mcFinish)){
var mcScore += 1;
}
```````````
It does not work, and gives me the errors
Scene 1, Layer 'actions', Frame 1, Line 50, Column 13 | 1086: Syntax error: expecting semicolon before equals. |
Scene 1, Layer 'actions', Frame 1, Line 52, Column 14 | 1086: Syntax error: expecting semicolon before plusassign. |
Everything works until the last part, adding the score, is added.
When said part, is added everything goes to shit.
thanks
hunterm28452256 wrote
var mcScore == 0;
if (mcSquare1.hitTest(mcFinish)){
var mcScore += 1;}
The double-equals operator is used for comparison, not assignment, and you're trying to declare a variable twice.
Also, you can use just ++ instead of += 1.
Copy link to clipboard
Copied
hunterm28452256 wrote
var mcScore == 0;
if (mcSquare1.hitTest(mcFinish)){
var mcScore += 1;}
The double-equals operator is used for comparison, not assignment, and you're trying to declare a variable twice.
Also, you can use just ++ instead of += 1.
Copy link to clipboard
Copied
double equal (==) is for testing equality. use a single equal (=) for assignment. and don't use 'var' twice and do type your variables:
var mcScore:int=0;
if(...){
mcScore++;
}
Find more inspiration, events, and resources on the new Adobe Community
Explore Now