开发者

Access GWT functions from Flex widget

I want to develop a GWT javascript application that must interact with a flex widget and fire events from 2 directions (flex to GWT and GWT to flex) For example I develop a function in GWT called onWidgetSelected(int widgetID){ ...} the generated javascript code does not conta开发者_如何转开发in the name of this function. So If I want to invoke it from flex through javascript call what should I do ?


@cwallenpoole correctly showed you how to call JS from Flex. But since GWT produces obfuscated JS, you will not be able to call GWT Java methods by their native names.

In order to make this work, you will need to "export" the method as described here: http://code.google.com/webtoolkit/doc/latest/DevGuideCodingBasicsJSNI.html#calling


Any time you want to talk about JS and AS talking to each other, you need to think about the EnternalInterface class in Flash. In this case, it sounds like you want to call addCallBack and call

EnternalInterface.addCallBack("onWidgetSelected",onWidgetSelected);

In JS:

document.getElementById("#swf-id").onWidgetSelected( 1 );

And to call JS from AS:

EnternalInterface.call("alert",1);
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜