Синтаксическая ошибка rightparen перед semicolon

hi i am new to AS3 in flash. i was trying to add a link button on my flash but i get the (1084: Syntax error: expecting rightparen before semicolon.) when i test it .

this is the code i created:

function myButtonPressed(event:MouseEvent){
navigateToURL(new URLRequest("http://pinoytoon.blogspot.com","_blank");

}

myButton.useHandCursor = true;
myButton.addEventListener(MouseEvent.MOUSE_DOWN, myButtonPressed);

please help me!!!

asked Jun 23, 2013 at 7:49

rey's user avatar

1

I think, you forgot close navigateToURL function with a rightparen:

function myButtonPressed(event:MouseEvent){
navigateToURL(new URLRequest("http://pinoytoon.blogspot.com","_blank"));
}

myButton.useHandCursor = true;
myButton.addEventListener(MouseEvent.MOUSE_DOWN, myButtonPressed);

i hope i could help you!

answered Jun 23, 2013 at 11:28

Hory's user avatar

HoryHory

162 bronze badges

What are the syntax errors?

PHP belongs to the C-style and imperative programming languages. It has rigid grammar rules, which it cannot recover from when encountering misplaced symbols or identifiers. It can’t guess your coding intentions.

Function definition syntax abstract

Most important tips

There are a few basic precautions you can always take:

  • Use proper code indentation, or adopt any lofty coding style.
    Readability prevents irregularities.

  • Use an IDE or editor for PHP with syntax highlighting.
    Which also help with parentheses/bracket balancing.

    Expected: semicolon

  • Read the language reference and examples in the manual.
    Twice, to become somewhat proficient.

How to interpret parser errors

A typical syntax error message reads:

Parse error: syntax error, unexpected T_STRING, expecting ; in file.php on line 217

Which lists the possible location of a syntax mistake. See the mentioned file name and line number.

A moniker such as T_STRING explains which symbol the parser/tokenizer couldn’t process finally. This isn’t necessarily the cause of the syntax mistake, however.

It’s important to look into previous code lines as well. Often syntax errors are just mishaps that happened earlier. The error line number is just where the parser conclusively gave up to process it all.

Solving syntax errors

There are many approaches to narrow down and fix syntax hiccups.

  • Open the mentioned source file. Look at the mentioned code line.

    • For runaway strings and misplaced operators, this is usually where you find the culprit.

    • Read the line left to right and imagine what each symbol does.

  • More regularly you need to look at preceding lines as well.

    • In particular, missing ; semicolons are missing at the previous line ends/statement. (At least from the stylistic viewpoint. )

    • If { code blocks } are incorrectly closed or nested, you may need to investigate even further up the source code. Use proper code indentation to simplify that.

  • Look at the syntax colorization!

    • Strings and variables and constants should all have different colors.

    • Operators +-*/. should be tinted distinct as well. Else they might be in the wrong context.

    • If you see string colorization extend too far or too short, then you have found an unescaped or missing closing " or ' string marker.

    • Having two same-colored punctuation characters next to each other can also mean trouble. Usually, operators are lone if it’s not ++, --, or parentheses following an operator. Two strings/identifiers directly following each other are incorrect in most contexts.

  • Whitespace is your friend.
    Follow any coding style.

  • Break up long lines temporarily.

    • You can freely add newlines between operators or constants and strings. The parser will then concretize the line number for parsing errors. Instead of looking at the very lengthy code, you can isolate the missing or misplaced syntax symbol.

    • Split up complex if statements into distinct or nested if conditions.

    • Instead of lengthy math formulas or logic chains, use temporary variables to simplify the code. (More readable = fewer errors.)

    • Add newlines between:

      1. The code you can easily identify as correct,
      2. The parts you’re unsure about,
      3. And the lines which the parser complains about.

      Partitioning up long code blocks really helps to locate the origin of syntax errors.

  • Comment out offending code.

    • If you can’t isolate the problem source, start to comment out (and thus temporarily remove) blocks of code.

    • As soon as you got rid of the parsing error, you have found the problem source. Look more closely there.

    • Sometimes you want to temporarily remove complete function/method blocks. (In case of unmatched curly braces and wrongly indented code.)

    • When you can’t resolve the syntax issue, try to rewrite the commented out sections from scratch.

  • As a newcomer, avoid some of the confusing syntax constructs.

    • The ternary ? : condition operator can compact code and is useful indeed. But it doesn’t aid readability in all cases. Prefer plain if statements while unversed.

    • PHP’s alternative syntax (if:/elseif:/endif;) is common for templates, but arguably less easy to follow than normal { code } blocks.

  • The most prevalent newcomer mistakes are:

    • Missing semicolons ; for terminating statements/lines.

    • Mismatched string quotes for " or ' and unescaped quotes within.

    • Forgotten operators, in particular for the string . concatenation.

    • Unbalanced ( parentheses ). Count them in the reported line. Are there an equal number of them?

  • Don’t forget that solving one syntax problem can uncover the next.

    • If you make one issue go away, but other crops up in some code below, you’re mostly on the right path.

    • If after editing a new syntax error crops up in the same line, then your attempted change was possibly a failure. (Not always though.)

  • Restore a backup of previously working code, if you can’t fix it.

    • Adopt a source code versioning system. You can always view a diff of the broken and last working version. Which might be enlightening as to what the syntax problem is.
  • Invisible stray Unicode characters: In some cases, you need to use a hexeditor or different editor/viewer on your source. Some problems cannot be found just from looking at your code.

    • Try grep --color -P -n "[x80-xFF]" file.php as the first measure to find non-ASCII symbols.

    • In particular BOMs, zero-width spaces, or non-breaking spaces, and smart quotes regularly can find their way into the source code.

  • Take care of which type of linebreaks are saved in files.

    • PHP just honors n newlines, not r carriage returns.

    • Which is occasionally an issue for MacOS users (even on OS  X for misconfigured editors).

    • It often only surfaces as an issue when single-line // or # comments are used. Multiline /*...*/ comments do seldom disturb the parser when linebreaks get ignored.

  • If your syntax error does not transmit over the web:
    It happens that you have a syntax error on your machine. But posting the very same file online does not exhibit it anymore. Which can only mean one of two things:

    • You are looking at the wrong file!

    • Or your code contained invisible stray Unicode (see above).
      You can easily find out: Just copy your code back from the web form into your text editor.

  • Check your PHP version. Not all syntax constructs are available on every server.

    • php -v for the command line interpreter

    • <?php phpinfo(); for the one invoked through the webserver.

    Those aren’t necessarily the same. In particular when working with frameworks, you will them to match up.

  • Don’t use PHP’s reserved keywords as identifiers for functions/methods, classes or constants.

  • Trial-and-error is your last resort.

If all else fails, you can always google your error message. Syntax symbols aren’t as easy to search for (Stack Overflow itself is indexed by SymbolHound though). Therefore it may take looking through a few more pages before you find something relevant.

Further guides:

  • PHP Debugging Basics by David Sklar
  • Fixing PHP Errors by Jason McCreary
  • PHP Errors – 10 Common Mistakes by Mario Lurig
  • Common PHP Errors and Solutions
  • How to Troubleshoot and Fix your WordPress Website
  • A Guide To PHP Error Messages For Designers — Smashing Magazine

White screen of death

If your website is just blank, then typically a syntax error is the cause.
Enable their display with:

  • error_reporting = E_ALL
  • display_errors = 1

In your php.ini generally, or via .htaccess for mod_php,
or even .user.ini with FastCGI setups.

Enabling it within the broken script is too late because PHP can’t even interpret/run the first line. A quick workaround is crafting a wrapper script, say test.php:

<?php
   error_reporting(E_ALL);
   ini_set("display_errors", 1);
   include("./broken-script.php");

Then invoke the failing code by accessing this wrapper script.

It also helps to enable PHP’s error_log and look into your webserver’s error.log when a script crashes with HTTP 500 responses.

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:
[as]
package com.cjm
{
class CoolClass {
function CoolClass () {
trace(“Something cool”)
}
}
[/as]
Good Code:
[as]
package com.cjm
{
class CoolClass {
function CoolClass () {
trace(“Something cool”)
}
}
}
[/as]
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:
[as]
me.myType == “keys” ? trace(keys);
[/as]
or
[as]
me.myType == “keys” ? trace(keys) ; trace(defs);
[/as]
Good Code:
[as]
me.myType == “keys” ? trace(keys) : trace(defs);
[/as]
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:
[as]
package com.cjm.somepackage {
public class {
}
}
[/as]
Good Code:
[as]
package com.cjm.somepackage {
public class MyClass {
}
}
[/as]
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:
[as]
public function ScrambleSpelling:void (s:String)
or
public function ScrambleSpelling(s:String:void
[/as]
Good Code:
[as]
public function ScrambleSpelling (s:String):void
[/as]
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:
[as]
tempArray.push((middle.splice(middle.length-1) * Math.random());
or
tempArray.push(middle.splice(middle.length-1) * Math.random();
[/as]
Good Code:
[as]
tempArray.push(middle.splice(middle.length-1) * Math.random());
[/as]
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:
[as]
package 1084_error
{
class 1084_error {
function 1084_error () {
var 1084_error:int = 123;
}
}
}
[/as]
Good Code:
[as]
package error_1084
{
class error_1084 {
function error_1084 () {
var error_1084:int = 123;
}
}
}
[/as]
P.S. It is probably not a good idea to give everything the same name as in the examples above.

1084: Syntax error: expecting rightparen before tripledot

Description:
This AS3 Error is reported when you add the ellipsis after the arguments parameter

Fix:
Make sure to add the ellipsis before the arguments parameter.

Incorrect:
[as]
public static function checkInheritance(propertyName:String, objects…) { }
[/as]
Correct:
[as]
public static function checkInheritance(propertyName:String, …objects) { }
[/as]

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.

koohikoo

New Here

,

/t5/animate-discussions/error-1086-expecting-semicolon-right-before-rightparen/td-p/10367239
Jan 23, 2019
Jan 23, 2019

Copy link to clipboard

Copied

The error is pointing me to line 8, column 68. the Problem is line 8 only has 32 columns. 

My goal is to make a TV screen that when clicked moves to the center and scales up, and then go back to the begining. Although it doesn’t even want to scale up.

  • Follow
  • 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

replies
8
Replies
8

Ned Murphy

LEGEND

,

/t5/animate-discussions/error-1086-expecting-semicolon-right-before-rightparen/m-p/10367240#M191438
Jan 23, 2019
Jan 23, 2019

Copy link to clipboard

Copied

Can you select the option to Permit Debugging in the Publish options and then show the complete error message you get after that?

  • Follow
  • 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

koohikoo

New Here

,

/t5/animate-discussions/error-1086-expecting-semicolon-right-before-rightparen/m-p/10367241#M191439
Jan 23, 2019
Jan 23, 2019

Copy link to clipboard

Copied

In Response To Ned Murphy

No change in the error message,

  • Follow
  • 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

Robert Mc Dowell

Advisor

,

/t5/animate-discussions/error-1086-expecting-semicolon-right-before-rightparen/m-p/10367242#M191440
Jan 23, 2019
Jan 23, 2019

Copy link to clipboard

Copied

In Response To koohikoo

remove all your comments and try again

  • Follow
  • 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

Colin Holgate

Community Expert

Community Expert

,

/t5/animate-discussions/error-1086-expecting-semicolon-right-before-rightparen/m-p/10367243#M191441
Jan 23, 2019
Jan 23, 2019

Copy link to clipboard

Copied

I’m not sure why the w property is in blue. If you’re setting width and height I would expect you to use .width and .height.

That aside, the main unusual thing is that you have two open comments and only one close comment. Not sure that should matter, but it could be worth fixing.

  • Follow
  • 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

koohikoo

New Here

,

/t5/animate-discussions/error-1086-expecting-semicolon-right-before-rightparen/m-p/10367244#M191442
Feb 28, 2019
Feb 28, 2019

Copy link to clipboard

Copied

In Response To Colin Holgate

Responding a bit late, haven’t had access to the project in a while. I tried both solutions that people replied with, but nether worked.

Why isnt this workingjwrkegtnaerglkkjae.PNG

  • Follow
  • 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

Ned Murphy

LEGEND

,

/t5/animate-discussions/error-1086-expecting-semicolon-right-before-rightparen/m-p/10367245#M191443
Mar 01, 2019
Mar 01, 2019

Copy link to clipboard

Copied

In Response To koohikoo

That should be «height» not «hight»

  • Follow
  • 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

Ned Murphy

LEGEND

,

/t5/animate-discussions/error-1086-expecting-semicolon-right-before-rightparen/m-p/10367246#M191444
Mar 01, 2019
Mar 01, 2019

Copy link to clipboard

Copied

In Response To koohikoo

It is possible something became corrupted in the file.  If you do not have much invested in this file yet, try creating a new one and type in the code rather than copying/using some other resource to enter it. 

  • Follow
  • 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

koohikoo

New Here

,

/t5/animate-discussions/error-1086-expecting-semicolon-right-before-rightparen/m-p/10367247#M191445
Mar 01, 2019
Mar 01, 2019

Copy link to clipboard

Copied

LATEST

In Response To Ned Murphy

The only code i’ve typed is the change in width and height, however i will attempt to do that

  • Follow
  • 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

sersche

FL Team
FL Team
Сообщения: 598
Зарегистрирован: 11 май 2010, 13:45

Re: ПРОСТОЙ ВОПРОС — ОТВЕТ

вот код

Код: Выделить всё

    var newtxt = txt;        dlina = newtxt.length;         for(var i:int = 9; i<(Math.ceil(dlina/10)); i+=10)            {                if (newtxt.charAt(i)==" ")                {                    newtxt = newtxt;                     break;                }                 else if(newtext.charAt(i+1)==" ")                {                    newtxt = newtxt.substr(0; i) + newtxt.substr(i+1; dlina-i-1);                    break;                }                else if(newtext.charAt(i-1)==" ")                {                    newtxt = newtxt.substr(0; i-1) + " " + newtxt.substr(i; dlina-i+1);                    break;                }                else if(newtext.charAt(i-1)!=" ")                {                    newtxt = newtxt.substr(0; i-1) + "-" + newtxt.substr(i; dlina-i+1);                    break;                }                                             dlina = newtxt.length;                            }

txt — переменная типа стринг.. туда я записываю чо пользователь ввел..

вот ошибки
описание // источник
1084: Синтаксическая ошибка: rightparen перед semicolon. // newtxt = newtxt.substr(0; i) + newtxt.substr(i+1; dlina-i-1);
1084: Синтаксическая ошибка: rightbrace перед i. // newtxt = newtxt.substr(0; i) + newtxt.substr(i+1; dlina-i-1);

и еще 4 штуки подобных..

помогите избавиться…

Аватара пользователя

совесть

Разработчик
Разработчик
Сообщения: 156
Зарегистрирован: 22 дек 2009, 23:58
Откуда: Санкт-Петербург

Re: ПРОСТОЙ ВОПРОС — ОТВЕТ

Сообщение

совесть » 10 июн 2010, 22:46

substr что делает? 0_о

наверно надо писать
substr(что-то там, что-то там)

то есть вместо «;» пишем «,»

Аватара пользователя

bodnar

Модератор
Модератор
Сообщения: 1399
Зарегистрирован: 03 апр 2010, 06:41

Re: ПРОСТОЙ ВОПРОС — ОТВЕТ

Сообщение

bodnar » 12 июн 2010, 11:48

В том как рекламу добавлять разобрались? В контейнере разобрались? Сами пробовали сделать? Как делали? Что не получилось? Почему у вас все спрашивать приходится?

Oleg.arh

Сообщения: 12
Зарегистрирован: 14 июн 2010, 15:25

Re: ПРОСТОЙ ВОПРОС — ОТВЕТ

Сообщение

Oleg.arh » 14 июн 2010, 15:29

Здравствуйте, я совсем новичок во Flash.
Такой вопрос!
В fla файле у меня есть текстовое поле — InputText, в которое пользователь должен ввести некий текст.
Как мне потом этот текст получить? в какую переменную он попадает? Объясните пожалуйста!

Аватара пользователя

grenium

Сообщения: 25
Зарегистрирован: 16 май 2010, 14:16

Re: ПРОСТОЙ ВОПРОС — ОТВЕТ

Сообщение

grenium » 17 июн 2010, 19:18

Подскажите пожалуйста, программирую на Abobe Flash CS4. flash выдаёт ошибку при использовании двух as файлов, как их можно объеденить в один as файл, по отдельности они работают отлично, а вот вместе не хотят

  • Синтаксическая ошибка return c
  • Синтаксис функции если ошибка
  • Синтаксическая ошибка missing operator semicolon or near draw
  • Синтаксис формулы если ошибка
  • Синтаксическая ошибка basic переменная sid уже определена