如何使用 ActionScript 访问 Remoteobject?
这个问题在很多地方都有讨论,但似乎没有一个解决方案对我有用。事情是这样的:在我的 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 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
在检查 RemoteObject 的代码后,我发现了以下代码片段:
这表明,如果定义了端点,RemoteObject-Class 将创建自己的通道集。尽管看起来这与我所做的相同,但事实并非如此,因为下面的代码实际上是有效的,与我的第一次尝试不同。
看来在定义通道集时必须非常小心。也许有人可以就此事启发我。
Upon inspecting the code of the RemoteObject, i found the following code snippet:
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.
Its seems one has to take great care when one defines the channelset. Maybe someone can enlighten me regarding this matter.