• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
Exit
0

Error 1084 sends me to the beginning of my code?

Community Beginner ,
Jun 01, 2022 Jun 01, 2022

Copy link to clipboard

Copied

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

Views

149

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
Community Expert ,
Jun 01, 2022 Jun 01, 2022

Copy link to clipboard

Copied

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

 

Votes

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
Community Beginner ,
Jun 01, 2022 Jun 01, 2022

Copy link to clipboard

Copied

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

Votes

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
Community Expert ,
Jun 01, 2022 Jun 01, 2022

Copy link to clipboard

Copied

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

Votes

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
Community Beginner ,
Jun 02, 2022 Jun 02, 2022

Copy link to clipboard

Copied

quote

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


 I don't know if it's the line that's actually causing it, but it sends me to the start of line 1

 

import flash.events.Event;

var moveSpeedX: int = 0;
var moveSpeedY: int = 0;
var boundaryState: int = 0;
var timerstop: int = 40;
var preventloop: Boolean = false;

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 boundaryfunction1(event: TimerEvent) {
	boundary.scaleX += 0.05;
	if (timerstop == 0) {
		boundarytimer1.removeEventListener(TimerEvent.TIMER, boundaryfunction1);
		timerstop = 40;
	} else if (timerstop !== 0) {
		timerstop -= 1;
	}
}


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) {
		if (preventloop == false) {
			var boundarytimer1: Timer = new Timer(15, 40);
			boundarytimer1.addEventListener(TimerEvent.TIMER, boundaryfunction1);
			boundarytimer1.start();
			preventloop = true;
		}
		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;
		}
	}
}

 

Votes

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
Community Expert ,
Jun 02, 2022 Jun 02, 2022

Copy link to clipboard

Copied

you have errors there, but not the one shown.  that's elsewhere in your code.  ie, it's difficult to help you debug your code when you don't show the relevant code.

Votes

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
Community Beginner ,
Jun 02, 2022 Jun 02, 2022

Copy link to clipboard

Copied

The problem is that if it just sends me to the start of line 1 in that layer, I have no idea what's actually causing the error or where it is.

Votes

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
Community Expert ,
Jun 02, 2022 Jun 02, 2022

Copy link to clipboard

Copied

that's one reason you should use class files. 

 

how many layers in frame 1 have code?

Votes

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
Community Beginner ,
Jun 06, 2022 Jun 06, 2022

Copy link to clipboard

Copied

I've decided that at this point it's probably better to just go back to before the error started. Thanks for your help anyways though.

Votes

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
Community Expert ,
Jun 06, 2022 Jun 06, 2022

Copy link to clipboard

Copied

LATEST

you're welcome.

Votes

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