Skip to main content
Participant
June 1, 2022
Question

Error 1084 sends me to the beginning of my code?

  • June 1, 2022
  • 1 reply
  • 334 views

So i keep getting an error telling me im missing a brace at the end of my program; 

"Scene 1, Layer 'Layer_1', Frame 1 1084: Syntax error: expecting rightbrace before end of program."

and when i try to go to the source it just sends me to the very start of my code.

 

(closer to the bottom you'll see a line of code that looks like it went to the next line for no reason, that's not actually how it shows when in actions panel, it's just wrapped around because there's no horizontal scrolling here.)

 

import flash.events.Event;


var moveSpeedX: int = 0;
var moveSpeedY: int = 0;
var boundaryState: int = 0;

stage.addEventListener(KeyboardEvent.KEY_DOWN, keydown);
stage.addEventListener(KeyboardEvent.KEY_UP, keyup);
stage.addEventListener(Event.ENTER_FRAME, gameloop);

function keydown(e: KeyboardEvent) {
	if (e.keyCode == Keyboard.LEFT) {
		moveSpeedX = -5;
	}
	if (e.keyCode == Keyboard.UP) {
		moveSpeedY = -5;
	}
	if (e.keyCode == Keyboard.RIGHT) {
		moveSpeedX = 5;
	}
	if (e.keyCode == Keyboard.DOWN) {
		moveSpeedY = 5;
	}
}

function keyup(e: KeyboardEvent) {

	if (e.keyCode == Keyboard.LEFT) {
		moveSpeedX = 0;
	}
	if (e.keyCode == Keyboard.UP) {
		moveSpeedY = 0;
	}
	if (e.keyCode == Keyboard.DOWN) {
		moveSpeedY = 0;
	}
	if (e.keyCode == Keyboard.RIGHT) {
		moveSpeedX = 0;
	}
}

function gameloop(e:Event) {
	movement();
	boundaries();
	displayHP();
	detecthit(); 
}
function movement() {
	player.y += moveSpeedY;
	player.x += moveSpeedX;
}


function boundaries() {
	if (boundaryState == 0) {
		if (player.y >= 295) {
			player.y = 295;
		}
		if (player.y <= 201) {
			player.y = 201;
		}
		if (player.x >= 322) {
			player.x = 322;
		}
		if (player.x <= 228) {
			player.x = 228;
		}
	}
	if (boundaryState == 1) {
			var boundarytimer1: Timer = new Timer(15, 40);
			boundarytimer1.addEventListener(TimerEvent.TIMER, boundaryfunction1); /*this isn't on a new line, it's just wrapped around due to the 
limitations of the code sample's box.*/
			boundarytimer1.start();
			function boundaryfunction1(event: TimerEvent) {
				boundary.scaleX += 0.05;
			}
			removeEventListener(TimerEvent.TIMER, boundaryfunction1);
		if (player.y >= 295) {
			player.y = 295;
		}
		if (player.y <= 201) {
			player.y = 201;
		}
		if (player.x >= 436) {
			player.x = 436;
		}
		if (player.x <= 111) {
			player.x = 111;
		}
	}
}
This topic has been closed for replies.

1 reply

kglad
Community Expert
Community Expert
June 1, 2022

nesting named functions is a problem:

 

function boundaries(){

function boundardyfunction1(){

}

}

 

change that to:

 

 

function boundaries(){

}

function boundardyfunction1(){

}

 

and is this:

 

removeEventListener(TimerEvent.TIMER, boundaryfunction1);

 

supposed to be:

 

boundarytime1.removeEventListener(TimerEvent.TIMER, boundaryfunction1);

 

Participant
June 1, 2022

I've fixed the potential causes you've pointed out, however it's still giving me the error and sending me to the beginning.

kglad
Community Expert
Community Expert
June 2, 2022

show your code, the error message and indicate the line number triggering the error.