07.14.07
Flash CS3 / Flex 2 Error #1084
ActionScript Error #1084: Syntax error: expecting rightbrace before end of program.
Error 1084 is the general error number for syntax errors. ActionScript Error #1084 can be any number of errors. I will keep this one up to date with all the variations I find and how to fix them.
AS3 Error 1084: Syntax error: expecting rightbrace before end of program
This is a very easy one. This error just means that you are most likely missing a right brace. Or you have nested code improperly.
Bad Code:
package com.cjm
{
class CoolClass {
function CoolClass () {
trace("Something cool")
}
}
Good Code:
package com.cjm
{
class CoolClass {
function CoolClass () {
trace("Something cool")
}
}
}
Please make note of the third bracket at the end of the good code.
ActionScript Error #1084: Syntax error: expecting colon before semicolon.
You will most likely get this error if you are using a ternary statement and you forget to use a colon, forgot the last part of your ternary, or you replace the colon with a semicolon. This is illustrated in the following example:
Bad Code:
me.myType == "keys" ? trace(keys);
or
me.myType == "keys" ? trace(keys) ; trace(defs);
Good Code:
me.myType == "keys" ? trace(keys) : trace(defs);
Flash/Flex Error #1084: Syntax error: expecting identifier before leftbrace.
Description:
This Flash/Flex Error is reported when you left out the name of your class. The 'identifier' that it is looking for is the name of your class.
Fix:
You will see in the code below that you just need to add in the name of your class and the error will go away.
Bad Code:
package com.cjm.somepackage {
public class {
}
}
Good Code:
package com.cjm.somepackage {
public class MyClass {
}
}
Flex/Flash Error #1084: Syntax error: expecting leftparen before colon.
or
Flex/Flash Error #1084: Syntax error: expecting rightparen before colon.
Description:
These AS3 Errors are reported when you the order of the parenthesis and colon are not in the proper place or the parenthesis is missing.
Fix:
The AS3 code below demonstrates the placement error. Properly order the items and the error will disappear. Also, make sure that a parenthesis is not missing. The 'Bad Code' gives an example of leftParen and then right paren in the order.
Bad Code:
public function ScrambleSpelling:void (s:String)
or
public function ScrambleSpelling(s:String:void
Good Code:
public function ScrambleSpelling (s:String):void
Flex/Flash Error #1084: Syntax error: expecting rightparen before semicolon.
Description:
This AS3 Error is reported most often when the parenthesis is missing.
Fix:
Make sure that a parenthesis is not missing. The 'Bad Code' gives an example of leftParen and then right paren in the order.
Bad Code:
tempArray.push((middle.splice(middle.length-1) * Math.random());
or
tempArray.push(middle.splice(middle.length-1) * Math.random();
Good Code:
tempArray.push(middle.splice(middle.length-1) * Math.random());
Flex/Flash Error #1084: Syntax error: expecting identifier before 1084.
Description:
This AS3 Error is reported when you have begun a package, class, function/method or variable with a numeric character rather than an Alpha character, _(underscore), or $(dollar sign). In the Flash Authoring environment it won't allow you to add numerics as the first character in an instance name or in the linkage but with code it just gives this crazy error.
Fix:
Make sure to name your package, class, function/method or variable with a Alpha character, _(underscore), or $(dollar sign).
Bad Code:
package 1084_error
{
class 1084_error {
function 1084_error () {
var 1084_error:int = 123;
}
}
}
Good Code:
package error_1084
{
class error_1084 {
function error_1084 () {
var error_1084:int = 123;
}
}
}
P.S. It is probably not a good idea to give everything the same name as in the examples above.
AS3 Error #1084 will rear it's many heads according to the particular syntax error at the moment. I will post every variation of this error that I can find.
Once again Happy Flashing
Magnus said,
August 7, 2007 at 3:18 am
Hi,
I don’t use Flash CS3 but a person I know does and they apparently got Error #1084: Syntax error: expecting rightbrace before semicolon. And that was for the code below, specifically for line two. I know this code works in my version of Flash I was wondering whether you could point out where this code could be incorrect for AS3…
for (var i=0; i
Curtis J. Morley said,
August 13, 2007 at 3:54 pm
The code is not incorrect just incomplete. The example you have is just the beginning of a complete block. Something like this:
for (var i=0; i<=20; i++){
trace(i)
}
This will produce the output 0 through 20 in the output window. If you have more code for me to look at I would be happy to help.
Thanks,
Curtis
ekion said,
January 9, 2008 at 12:45 pm
Hi mate,
I’ve a new kind of this error :
” 1084 : Syntax error : expecting rightparen before colon ”
Do not understant really ^^
Curtis J. Morley said,
January 15, 2008 at 9:10 pm
ekion,
I have put up some new examples that handle the case that you are talking about. Hope this helps. I like your site and look forward to seeing the redesign.
Thanks,
Curtis J. Morley
curtismorley.com » New Scenarios of AS3 Error #1084 said,
January 15, 2008 at 9:32 pm
[...] I’ve added 3 new scenarios to AS3 error 1084. [...]
curtismorley.com » Flex / Flash ActionScript Error #1095 said,
January 18, 2008 at 4:12 pm
[...] you out when you improperly use single quotes. You will most likely get AS3 syntax error 1083 and syntax error 1084 after this this one. These can most likely be ignored and will go away once the 1095 Error is [...]
John Rivas said,
January 20, 2008 at 1:17 am
1084: Syntax error: expecting identifier before this.
John Rivas said,
January 20, 2008 at 1:19 am
Sorry forgot to post syntax:
var this['n'+i]:Sprite = new Sprite();
curtismorley.com » Search Engine Optimization Example said,
June 2, 2008 at 4:54 pm
[...] AS3 Error 1084 - #1,2 hit on Google [...]
zach seikel said,
June 27, 2008 at 11:08 am
i got one that said :
1084: Syntax error: expecting rightparen before dot.
here is my code:
function startGame(event.MouseEvent) {
gotoAndStop(”playgame”);
}
stop();
zach seikel said,
June 27, 2008 at 1:57 pm
ok i fixed that one but now i have an error that looks like this:
1084: Syntax error: expecting identifier before playgame.
the source is:
event.”playgame”.parent.gotoAndStop(”playgame”);
here is my code:
function startGame(event:MouseEvent){
event.”playgame”.parent.gotoAndStop(”playgame”);
}
stop();
any help?
Curtis J. Morley said,
June 27, 2008 at 6:07 pm
Zach,
Try this code
function startGame (e:MouseEvent)
{
gotoAndStop(”playgame”);
}
The difference is the semicolon in place of the dot. The semicolon “Types” the parameter being passed instead of trying to access a method/parameter of a method.
You would call this function with an evenListener like I have below.
SomeObject_mc.addEventListener(MouseEvent.CLICK, startGame)
Hopefully this helps you solve Flash Error1084
Happy Flashing,
Curtis J. Morley
Aaron said,
June 28, 2008 at 8:32 am
So I have a video clip in a fla, an as file named MainTimeline that I use for the document class in the fla. But I am getting a error 1084: expecting identifier before 1: package 1_fla
I am just missing something I am not seeing or did I do something wrong?
here is the code in the as file (no code at all in the fla):
package 1_fla
{
import flash.display.*;
dynamic public class MainTimeline extends MovieClip
{
public function MainTimeline()
{
addFrameScript(1796, frame1797, 1797, frame1798, 1798, frame1799);
return;
}// end function
function frame1798()
{
stop();
return;
}// end function
function frame1799()
{
stop();
return;
}// end function
function frame1797()
{
ExternalInterface.call(”nextPage”, null);
return;
}// end function
} // end class
} // end package
Curtis J. Morley said,
June 28, 2008 at 3:54 pm
Aaron,
Thanks for submitting this comment. I have added the solution to the list of errors in the main post because of your bug. This one is actually a simple yet very misleading one. The reason it pops up this error is because you started your package name with a number.
package 1084_error{
}
In Flash you cannot start any name with a number or else you will get an error. I am surprised that Adobe assigned this error to this problem. The solution is to simple start with Alpha characters, $(dollar sign) or _(underscore).
package error_1084{
}
Adam said,
July 2, 2008 at 8:50 am
Error1084: Syntax error: expecting in before colon.
curtismorley.com » New info on Error Flex/Flash Error #1084: Syntax error: expecting identifier before 1084. said,
July 3, 2008 at 11:03 am
[...] to Aaron I have added another solution to AS3 Error 1084 that deals with using numeric characters. Check out the fix for ActionScript Error [...]
Curtis J. Morley said,
July 3, 2008 at 9:46 pm
Adam,
It looks like the last part of your comments didn’t make it. I would be happy to help with more info.
Thanks,
Curtis J. Morley
sat said,
August 2, 2008 at 2:58 am
please i have this problem
1084 syntax error
expecting colon before 67
this is my code
package
{
import flash.system.*;
import mx.core.*;
import mx.managers.*;
public class _Player_mx_managers_SystemManager extends SystemManager implements IFlexModuleFactory
{
public function _Player_mx_managers_SystemManager()
{
return;
}// end function
override public function info() : Object
{
return {currentDomain:ApplicationDomain.currentDomain, backgroundAlpha:”0″, backgroundColor:”white”, creationComplete:”init()”, fonts:{Frutiger 67BoldCn:{regular:true, bold:false, italic:false, boldItalic:false}, Tahoma:{regular:true, bold:true, italic:false, boldItalic:false}}, horizontalScrollPolicy:”off”, layout:”absolute”, mainClassName:”Player”, minHeight:”330″, minWidth:”490″, mixins:["_Player_FlexInit", "_alertButtonStyleStyle", "_ControlBarStyle", "_ScrollBarStyle", "_activeTabStyleStyle", "_textAreaHScrollBarStyleStyle", "_ToolTipStyle", "_VideoDisplayStyle", "_ProgressBarStyle", "_comboDropDownStyle", "_ContainerStyle", "_textAreaVScrollBarStyleStyle", "_globalStyle", "_windowStatusStyle", "_windowStylesStyle", "_PanelStyle", "_activeButtonStyleStyle", "_HSliderStyle", "_errorTipStyle", "_richTextEditorTextAreaStyleStyle", "_CursorManagerStyle", "_todayStyleStyle", "_dateFieldPopupStyle", "_plainStyle", "_dataGridStylesStyle", "_ApplicationStyle", "_SWFLoaderStyle", "_headerDateTextStyle", "_ButtonStyle", "_opaquePanelStyle", "_weekDayStyleStyle", "_headerDragProxyStyleStyle", "_ThumbnailWatcherSetupUtil", "_MainLayoutWatcherSetupUtil", "_ThumbnailDisplayWatcherSetupUtil", "_VideoPlayerWatcherSetupUtil", "_FeedTabWatcherSetupUtil", "_ItemDetailsWatcherSetupUtil"], pageTitle:”Preview Player”, resize:”resizeHandler()”};
}// end function
override public function create(… args) : Object
{
var _loc_2:String;
var _loc_3:Class;
var _loc_4:Object;
if (args.length == 0 || args[0] is String)
{
_loc_2 = null;
if (args.length == 0)
{
_loc_2 = “Player”;
}
else
{
_loc_2 = String(args[0]);
}// end else if
_loc_3 = Class(getDefinitionByName(_loc_2));
if (_loc_3 != null)
{
_loc_4 = new _loc_3;
if (_loc_4 is IFlexModule)
{
IFlexModule(_loc_4).moduleFactory = this;
}// end if
return _loc_4;
}
else
{
return null;
}// end else if
}
else
{
}// end else if
return super.create.apply(this, args);
}// end function
}
}
Alex said,
August 27, 2008 at 9:18 am
Thanks for the blogs homie, you’ve helped a great deal a number of times.
Kudos and take care.