帮助actionscript 3语法

时间:2015-02-06 16:48:17

标签: actionscript-3 actionscript

我想在这里提供帮助,这是我的actionscript3代码。

每次编译我都会收到错误。

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

这是代码

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

第二个错误

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

第二个错误说:

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

有人可以帮助我,提前谢谢。

更新:在分号之前添加右括号后,它会产生更多错误。

2 个答案:

答案 0 :(得分:1)

第一个错误是非常明确的,你需要一个catch块。空的try块没用。

网站上的语法。

try {
    //Your code

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

    trace("Error found: " + e);

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

Website reference in french

答案 1 :(得分:0)

如果没有捕获,就不能使用try。我们的想法让我们尝试这段代码,如果遇到任何问题,请停止并执行catch中的内容。无论try还是catch被执行,finally都用于执行你想要运行的代码。

在第一个错误中: 你只是错过了一个捕获。也可能在try语句中包含一些代码,否则无意义使用。

示例:

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

第二个错误:你可能错过了一个'}'在那个功能的某个地方。缩进您的代码,以便您可以清楚地看到这些代码,并且您可以匹配每个' {'及其相应的'}'

相关问题