mx:method、mx.rpc.remoting.mxml.RemoteObject 和子类化 mx.rpc.remoting.mxml.RemoteObject 的问题

发布于 2024-08-31 13:06:17 字数 1688 浏览 0 评论 0原文

我正在寻找 RemoteObject 的子类。而不是:

<mx:RemoteObject ... >
    <mx:method ... />
    <mx:method ... />
</mx:RemoteObject>

我想做类似的事情:

<remoting:CustomRemoteObject ...>
    <mx:method ... />
    <mx:method ... />
</remoting:CustomRemoteObject>

其中 CustomRemoteObject 扩展 mx.rpc.remoting.mxml.RemoteObject 像这样:

package remoting
{
    import mx.rpc.remoting.mxml.RemoteObject;

    public class CustomRemoteObject extends RemoteObject
    {
        public function CustomRemoteObject(destination:String=null)
        {
            super(destination);
        }
    }
}

但是,当这样做并声明 如上 MXML 中的 CustomRemoteObject,flex 编译器显示错误:

无法解析到组件实现

起初,我认为这与 CustomRemoteObject 未能执行某些操作有关,尽管如此(或此后),除了名称之外,它没有任何变化 因此,我将源代码从 mx.rpc.remoting.mxml.RemoteObject 复制到 CustomRemoteObject 中并进行修改,因此唯一的区别是重构类和包名称。但仍然是同样的错误。

与许多 MXML 组件不同,我无法在 FlashBuilder 中 cmd+单击 来打开源代码。同样,我没有在 mx.rpc.remoting.mxml.RemoteObjectmx.rpc.remoting.RemoteObjectmx.rpc.remoting 中找到引用.AbstractService,并在网上找到其来源未成功。

这引出了标题中的问题:

  • 到底是什么?? (是的,我知道这是一个 RemoteObject 方法的声明,并且我知道如何使用它,但它对于其他组件来说很特殊)
  • 为什么我尝试子类化 RemoteObject 失败,尽管它实际上是重命名?也许根源在于,为什么 mx.rpc.remoting.mxml.RemoteObject 作为 MXML 声明可以接受 子标签,但所述类的源却不能仅在名义上重构时?
  • I am looking to subclass RemoteObject. Instead of:

    <mx:RemoteObject ... >
        <mx:method ... />
        <mx:method ... />
    </mx:RemoteObject>
    

    I want to do something like:

    <remoting:CustomRemoteObject ...>
        <mx:method ... />
        <mx:method ... />
    </remoting:CustomRemoteObject>
    

    where CustomRemoteObject extends mx.rpc.remoting.mxml.RemoteObject like so:

    package remoting
    {
        import mx.rpc.remoting.mxml.RemoteObject;
    
        public class CustomRemoteObject extends RemoteObject
        {
            public function CustomRemoteObject(destination:String=null)
            {
                super(destination);
            }
        }
    }
    

    However, when doing so and declaring a CustomRemoteObject in MXML as above, the flex compiler shows the error:

    Could not resolve <mx:method> to a component implementation

    At first I thought it had something to do with CustomRemoteObject failing to do something, despite that (or since) it had no change except as to the name. So, I copied the source from mx.rpc.remoting.mxml.RemoteObject into CustomRemoteObject and modified it so the only difference was a refactoring of the class and package name. But still, the same error.

    Unlike many MXML components, I cannot cmd+click <mx:method> in FlashBuilder to open the source. Likewise, I have not found a reference in mx.rpc.remoting.mxml.RemoteObject, mx.rpc.remoting.RemoteObject, or mx.rpc.remoting.AbstractService, and have been unsuccessful in find its source online.

    Which leads me to the questions in the title:

  • What exactly is <mx:method>? (yes, I know it's a declaration of a RemoteObject method, and I know how to use it, but it's peculiar in regard to other components)
  • Why did my attempt at subclassing RemoteObject fail, despite it effectually being a rename? Perhaps the root, why can mx.rpc.remoting.mxml.RemoteObject as an MXML declaration accept <mx:method> child tags, yet the source of said class cannot when refactored in name only?
  • 如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

    扫码二维码加入Web技术交流群

    发布评论

    需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

    评论(1

    ┾廆蒐ゝ 2024-09-07 13:06:17

    您正在查看的语法(“mx:method”)是一种在 MXML 而不是 ACtionScript 中定义属性的方法。如果这是扩展“标准”UIComponent,您可以这样做:

    <remoting:CustomRemoteObject ...>
        <remoting:method ... />
        <remoting:method ... />
    </remoting:CustomRemoteObject>
    

    但是,由于 method 不是 RemoteObject 上的属性,因此幕后可能存在一些编译器魔法。我敢打赌它将“方法”标签变成操作数组。

    您可能需要手动执行此操作,如下所示:

    <remoting:CustomRemoteObject ...>
      <remoting:Operations>
        <remoting:method ... />
        <remoting:method ... />
       </remoting:Operations>
    </remoting:CustomRemoteObject>
    

    但是,您可能必须解析代码和/或在调试模式下运行和/或查看生成的动作脚本以准确弄清楚发生了什么以及“方法”如何被转换成操作数组。

    我认为 SDK 中提供了远程处理类的源代码;但也许只是开源 SDK,而不是 Adob​​e 支持的 SDK。您可以在 opensource.adobe.com 下载开源 SDK。

    本文的一半内容是猜测。

    The syntax you're looking at ('mx:method') is a way to define properties in MXML instead of in ACtionScript. IF this were extending a "standard" UIComponent, you'd do this:

    <remoting:CustomRemoteObject ...>
        <remoting:method ... />
        <remoting:method ... />
    </remoting:CustomRemoteObject>
    

    However, since method is not a property on RemoteObject, there is probably some compiler magic behind the scenes. I bet it turns the "methods" tags into the operation array.

    You'll probably need to do that manually, something like this:

    <remoting:CustomRemoteObject ...>
      <remoting:Operations>
        <remoting:method ... />
        <remoting:method ... />
       </remoting:Operations>
    </remoting:CustomRemoteObject>
    

    But, you may have to parse through code and/or run in debug mode and/or review the generated actionscript to figure out exactly what is going on and how "method" is turned into the operations array.

    I thought the source of the remoting classes was available in the SDK; but perhaps just the open source SDK not the Adobe supported SDK. You can download the open source SDK at opensource.adobe.com

    Half of this post is guessing.

    ~没有更多了~
    我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
    原文