AS 3中是否有装饰器/宏/注释?

时间:2009-06-10 09:01:25

标签: flex actionscript code-generation

我正在寻找相应的Python装饰器/ Lisp宏/ Java注释(是的,我知道这些不一定等同于它们自己)。提供类似功能的工具也很棒(我在Linux上使用Eclipse的Flex Builder插件)。

我正在编写一个Flex应用程序,这就是我想要完成的任务:

我在不同的类中封装了各种远程功能集(有时称为“Messaging Gateways”或“Remote Proxies”),其中每个方法都镜像服务器上的方法,如下所示:

class UserManagementService extends MyHttpService {
  //...
  private final _urlBase:String = "http://example.com/services/users"
  //...

  public function usrGet(ix:int):User
  {
     url = urlBase + "/get";
     mp:Dictionary = new Dictionary();
     mp["ix"] = ix;
     result:User = this._service.varSend(url, this.sEncodeParams(mp), Class("User"));
     return result;
  }
  //...
}

由于我已经在函数声明中提供了远程函数的参数和返回类型,所以最好只添加URL后缀,就像这样(Python启发的伪代码):

@remotify("/get")
public function usrGet(ix:int):User { }

现在,这不是很整洁吗? ; - )

1 个答案:

答案 0 :(得分:6)

您可以在ActionScript中添加所谓的“元数据”,如下所示:

[Remotify(prop="value")]

更多信息请点击此处:

http://www.adobe.com/cfusion/communityengine/index.cfm?event=showdetails&productId=2&postId=11907