{"id":5968,"date":"2014-04-11T06:53:53","date_gmt":"2014-04-11T06:53:53","guid":{"rendered":"https:\/\/unknownerror.org\/index.php\/2014\/04\/11\/calling-a-function-inside-a-function-converting-as2-to-as3-collection-of-common-programming-errors\/"},"modified":"2014-04-11T06:53:53","modified_gmt":"2014-04-11T06:53:53","slug":"calling-a-function-inside-a-function-converting-as2-to-as3-collection-of-common-programming-errors","status":"publish","type":"post","link":"https:\/\/unknownerror.org\/index.php\/2014\/04\/11\/calling-a-function-inside-a-function-converting-as2-to-as3-collection-of-common-programming-errors\/","title":{"rendered":"Calling a function inside a function &#8211; converting AS2 to AS3-Collection of common programming errors"},"content":{"rendered":"<p>I currently have some code from here (https:\/\/github.com\/jmhnilbog\/Nilbog-Lib-AS2\/blob\/master\/mx\/mx\/remoting\/NetServiceProxy.as) which converts a function into a function. This code is shown below:<\/p>\n<pre><code> private var _allowRes:Boolean= false;\n function __resolve( methodName:String ):Function {\n     if( _allowRes ) {\n         var f = function() :Object {\n             \/\/ did the user give a default client when he created this NetServiceProxy? \n             if (this.client != null) {\n                 \/\/ Yes. Let's create a responder object.\n                 arguments.unshift(new NetServiceProxyResponder(this, methodName));\n             }\n             else {\n                 if (typeof(arguments[0].onResult) != \"function\") {\n                      mx.remoting.NetServices.trace(\"NetServices\", \"warning\", 3, \"There is no defaultResponder, and no responder was given in call to \" + methodName);\n                      arguments.unshift(new NetServiceProxyResponder(this, methodName));\n                 }\n             }\n\n             if(typeof(this.serviceName) == \"function\")\n                 this.serviceName = this.servicename;\n             arguments.unshift(this.serviceName + \".\" + methodName);\n\n             return( this.nc.call.apply(this.nc, arguments));\n         };\n         return f;\n     }\n     else {\n       return null;\n     }\n }\n<\/code><\/pre>\n<p>Basically what the code is designed to do is return a new function (returned as f) which performs the correct server operates. However, if I try and use this syntax in AS3, I get the following two errors:<\/p>\n<pre><code>Error: Syntax error: expecting semicolon before colon.\nError: Syntax error: else is unexpected.\n<\/code><\/pre>\n<p>How would I go about doing this? I know this is someone else&#8217;s code, but I am trying to get the old AS1\/2 mx.remoting functionality working in AS3. Cheers.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>I currently have some code from here (https:\/\/github.com\/jmhnilbog\/Nilbog-Lib-AS2\/blob\/master\/mx\/mx\/remoting\/NetServiceProxy.as) which converts a function into a function. This code is shown below: 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 != [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[],"class_list":["post-5968","post","type-post","status-publish","format-standard","hentry","category-uncategorized"],"_links":{"self":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/posts\/5968","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/comments?post=5968"}],"version-history":[{"count":0,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/posts\/5968\/revisions"}],"wp:attachment":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/media?parent=5968"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/categories?post=5968"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/tags?post=5968"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}