如何使用 ActionScript 访问 Remoteobject?

发布于 2024-11-08 22:29:54 字数 911 浏览 0 评论 0原文

这个问题在很多地方都有讨论,但似乎没有一个解决方案对我有用。事情是这样的:在我的 mxml 代码中,一切都完美运行:

<s:RemoteObject id="remotetest" destination="Hibernatetest" endpoint="http://praiseJESUS/blazeds/messagebroker/amf" result="remotetest_resultHandler(event)" fault="remotetest_faultHandler(event)"/>

<s:Button x="1248" y="401" label="Laden" click="remotetest.getCells()"/>

protected function remotetest_resultHandler(event:ResultEvent):void
{
  var cellList:ArrayCollection = event.result as ArrayCollection;
}

现在,这完美运行。另一方面不起作用的是:

var ro:RemoteObject = new RemoteObject;
var cs:ChannelSet = new ChannelSet;
var c:Channel = new AMFChannel("my-amf","http://JESUSAGAIN/blazeds/messagebroker/amf");
cs.addChannel(c);
ro.channelSet = cs;
ro.destination = "MyClass";
ro.source = "myNamespace.MyClass";
ro.getOperation("myfunction()").send();

这应该起作用 - 不知道为什么它不起作用。有什么提示吗?

This questions is discussed in many places, but none of the solutions seem to work for me. Heres the thing: In my mxml-code everything works perfectly:

<s:RemoteObject id="remotetest" destination="Hibernatetest" endpoint="http://praiseJESUS/blazeds/messagebroker/amf" result="remotetest_resultHandler(event)" fault="remotetest_faultHandler(event)"/>

<s:Button x="1248" y="401" label="Laden" click="remotetest.getCells()"/>

protected function remotetest_resultHandler(event:ResultEvent):void
{
  var cellList:ArrayCollection = event.result as ArrayCollection;
}

Now, this works perfectly. What doesnt work on the other hand is this:

var ro:RemoteObject = new RemoteObject;
var cs:ChannelSet = new ChannelSet;
var c:Channel = new AMFChannel("my-amf","http://JESUSAGAIN/blazeds/messagebroker/amf");
cs.addChannel(c);
ro.channelSet = cs;
ro.destination = "MyClass";
ro.source = "myNamespace.MyClass";
ro.getOperation("myfunction()").send();

This SHOULD work - dunno why it doesnt. Any hints?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

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

发布评论

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

评论(1

岛徒 2024-11-15 22:29:54

在检查 RemoteObject 的代码后,我发现了以下代码片段:

mx_internal function initEndpoint():void
{
    if (endpoint != null)
    {
        var chan:Channel;
        if (endpoint.indexOf("https") == 0)
        {
            chan = new SecureAMFChannel(null, endpoint);
        }
        else
        {
            chan = new AMFChannel(null, endpoint);
        }
        channelSet = new ChannelSet();
        channelSet.addChannel(chan);
    }
}

这表明,如果定义了端点,RemoteObject-Class 将创建自己的通道集。尽管看起来这与我所做的相同,但事实并非如此,因为下面的代码实际上是有效的,与我的第一次尝试不同。

var ro:RemoteObject = new RemoteObject("Hibernatetest");
            ro.endpoint = "http://Jesus/blazeds/messagebroker/amf";
            ro.myfunction();

看来在定义通道集时必须非常小心。也许有人可以就此事启发我。

Upon inspecting the code of the RemoteObject, i found the following code snippet:

mx_internal function initEndpoint():void
{
    if (endpoint != null)
    {
        var chan:Channel;
        if (endpoint.indexOf("https") == 0)
        {
            chan = new SecureAMFChannel(null, endpoint);
        }
        else
        {
            chan = new AMFChannel(null, endpoint);
        }
        channelSet = new ChannelSet();
        channelSet.addChannel(chan);
    }
}

This shows, that if an endpoint is defined, the RemoteObject-Class will create its own channelset. Allthough it might seem that this is the same as what I did, i cannot be, for the following piece of code actually works, unlike my first attempt.

var ro:RemoteObject = new RemoteObject("Hibernatetest");
            ro.endpoint = "http://Jesus/blazeds/messagebroker/amf";
            ro.myfunction();

Its seems one has to take great care when one defines the channelset. Maybe someone can enlighten me regarding this matter.

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