user4538092
user4538092

Reputation:

Hel­p with actionscript 3 syntax

I would like your help here, this is my actionscript3 code.

Everytime I compile I get error.

Line 1537 1073: Syntax error: expecting a catch or a finally clause.

This is the code

 {
            try
            {
            }
            _loc_3.badge.gotoAndStop(param1.split(":")[2]);
  }

And the second error

{
            try
            {
            }
            _loc_3.badge.gotoAndStop(param1.split(":")[2]);
}

The second error says:

Line 1537 1084: Syntax error: expecting rightbrace before semicolon.

Could anyone help me here, thanks in advance.

UPDATE: After I add a right brace before the semicolon it gives more errors.

Upvotes: 0

Views: 121

Answers (2)

Avi
Avi

Reputation: 96

A try cannot be used without a catch. the idea there is lets try this piece of code and if we run into any problems stop and execute the content of whatever is in the catch. the finally is used for executing code that you want to run regardless of whether the try or catch gets executed.

in the first error: you are just missing a catch. also maybe include some code into the try statement, otherwise its pointless to use.

example:

try
{
     //try to feed my dog
     feedDog();
}
//if some error occurs in feedDog() then the catch will be called
//if you want to catch specific exceptions 
//then specify its type instead of Exception
catch (Exception e)
{
   trace("unable to feed dog");
}
//this will execute whether the dog was fed successfully or not
finally
{
   trace("leave");
}

with the second error: you are probably missing a '}' somewhere in that function. Indent your code so that these will become clearly visible to you and you can match every '{' with its corresponding '}'

Upvotes: 0

Nambew
Nambew

Reputation: 640

The first error is really explicit, you need a catch block. The empty try block is useless.

The syntax found on a website.

try {
    //Your code

} 
catch(e:Error) { // Error handling

    trace("Error found: " + e);

} 
//Optional
finally {
    // Closing connection for example.
}

Website reference in french

Upvotes: 1

Related Questions