在函数内部调用函数 - 将AS2转换为AS3

时间:2014-01-30 03:46:29

标签: actionscript-3 actionscript-2

我目前有一些代码(https://github.com/jmhnilbog/Nilbog-Lib-AS2/blob/master/mx/mx/remoting/NetServiceProxy.as)将函数转换为函数。此代码如下所示:

 private var _allowRes:Boolean= false;
 function __resolve( methodName:String ):Function {
     if( _allowRes ) {
         var f = function() :Object {
             // did the user give a default client when he created this NetServiceProxy? 
             if (this.client != null) {
                 // Yes. Let's create a responder object.
                 arguments.unshift(new NetServiceProxyResponder(this, methodName));
             }
             else {
                 if (typeof(arguments[0].onResult) != "function") {
                      mx.remoting.NetServices.trace("NetServices", "warning", 3, "There is no defaultResponder, and no responder was given in call to " + methodName);
                      arguments.unshift(new NetServiceProxyResponder(this, methodName));
                 }
             }

             if(typeof(this.serviceName) == "function")
                 this.serviceName = this.servicename;
             arguments.unshift(this.serviceName + "." + methodName);

             return( this.nc.call.apply(this.nc, arguments));
         };
         return f;
     }
     else {
       return null;
     }
 }

基本上代码的目的是返回一个执行正确服务器操作的新函数(返回为f)。但是,如果我尝试在AS3中使用此语法,则会出现以下两个错误:

Error: Syntax error: expecting semicolon before colon.
Error: Syntax error: else is unexpected.

我该怎么做呢?我知道这是别人的代码,但我试图让旧的AS1 / 2 mx.remoting功能在AS3中运行。欢呼声。

0 个答案:

没有答案