Invoking ActionScript method from GWT

26 views
Skip to first unread message

mark morreny

unread,
Oct 24, 2008, 2:47:17 AM10/24/08
to Google-We...@googlegroups.com
Hi,
 
I am hoping someone may know anything about using gwt-fabridge.jar. I am trying to use gwt-fabridge to invoke an ActionScript method when a gwt button is clicked.
In my ActionScript (MyTest.as), I have:
 
 public function record():void {
           ns.publish("abc","record");
         }             
public function resume():void {
           ns.resume();
         }
public function pause():void {
             ns.pause();
          }
public function stop():void {
          ns.close();
         }
In GWT, I have:
 
SWFParams params = new SWFParams("MyTest1.swf", new Integer(400),
    new Integer(400));
  params.addVar("bridgeName", "audio");
 swfWidget = new SWFABridgeWidget(params);
 add(swfWidget);
  swfWidget.show();
  // add initialization listener
  swfWidget.addInitializationListener(AudioRecorder.this);
  recordButton.addListener(new ButtonListenerAdapter()  {
   public void onClick(Button button, EventObject e) {
    BridgeParameter params = new BridgeParameter();

    BridgeObject flexApp = swfWidget.root();
   
    flexApp.invokeMethod("record",params.getParameter());
    
   }
   
  });        
 
 
I have also tried to replace the invokeMethod line with:
 
BridgeParameter params = new BridgeParameter();
    params.addParameter("testfile");
    params.addParameter("record");
  flexApp.getObject("ns").invokeMethod("publish",params.getParameter());
   
That way, I can invoke on the NetStream object directly. 
 
However, both solution does not work.  The record method is still not invoked. 
 
Does anyone know what is wrong with my code?
 
Thanks alot for all your help in adavance.
 
Regards,
Mark
 
 
 

mark morreny

unread,
Oct 24, 2008, 3:37:09 AM10/24/08
to Google-We...@googlegroups.com
Hi,
 
I traced the code and found that GWT hangs when executing:
BridgeObject flexApp = swfWidget.root();
I have checked that swfWidget is not null and here is the way I created swfWidget:
SWFParams params = new SWFParams("MyTest.swf", new Integer(400),
    new Integer(400));
  params.addVar("bridgeName", "audio");
  swfWidget = new SWFABridgeWidget(params);
BridgeObject flexApp2 = swfWidget.root();
Does anyone know why?
 
The error I am getting is :
 
[ERROR] Uncaught exception escaped
com.google.gwt.core.client.JavaScriptException: (TypeError): '$wnd.FABridge[...]' is null or not an object
 number: -2146823281
 description: '$wnd.FABridge[...]' is null or not an object
 at org.argunet.gwt.fabridge.client.SWFABridgeWidget.getBridgeRoot(Native Method)
 at org.argunet.gwt.fabridge.client.SWFABridgeWidget.root(SWFABridgeWidget.java:79)
 at com.yht.ui.gwt.client.widget.util.AudioRecorder.init(AudioRecorder.java:69)
 at com.yht.ui.gwt.client.widget.util.AudioRecorder.<init>(AudioRecorder.java:39)
 at com.yht.ui.gwt.client.widget.MainPanel.getData(MainPanel.java:194)
 at com.yht.ui.gwt.client.widget.util.BasePanel.getStore(BasePanel.java:288)
 at com.yht.ui.gwt.client.widget.util.BasePanel.getAccordionNav(BasePanel.java:156)
 at com.yht.ui.gwt.client.widget.util.BasePanel.init(BasePanel.java:83)
 at com.yht.ui.gwt.client.widget.MainPanel.<init>(MainPanel.java:118)
 at com.yht.ui.gwt.client.Application$1.onSuccess(Application.java:50)
 at com.yht.ui.gwt.client.Application$1.onSuccess(Application.java:1)
 at com.google.gwt.user.client.rpc.impl.RequestCallbackAdapter.onResponseReceived(RequestCallbackAdapter.java:215)
 at com.google.gwt.http.client.Request.fireOnResponseReceivedImpl(Request.java:254)
 at com.google.gwt.http.client.Request.fireOnResponseReceivedAndCatch(Request.java:226)
 at com.google.gwt.http.client.Request.fireOnResponseReceived(Request.java:217)

 
Thanks in advance for all your help.
 
Mark

Mark Renouf

unread,
Oct 24, 2008, 3:53:26 PM10/24/08
to Google Web Toolkit
I've built some apps using Flash via ExternalInterface. It's my
experience that it just doesn't work correctly in hosted mode. Also,
IE, for some reason, unless I attached the Flash object directly to
the document, it would not work.

Sumit Chandel

unread,
Oct 27, 2008, 2:25:36 PM10/27/08
to Google-We...@googlegroups.com
Hi Mark,

Are you encountering this error message in hosted mode? If so, the reason why is because, for the moment, Flash plug-ins aren't available on the embedded hosted mode browser. What you can do is test out your Flash interactions in web mode by compiling and running your GWT application in a regular browser.

You can workaround the error messages in hosted mode by adding GWT.isScript() conditionals around code that is interoperating with your Flash components. These will make sure the code gets executed in web mode and skipped in hosted mode. Once hosted mode goes out-of-process in a near future release of GWT, this will no longer be an issue and you will be able to use hosted mode with Flash or any other browser plug-ins.

Hope that helps,
-Sumit Chandel

mark morreny

unread,
Jan 8, 2009, 2:49:56 AM1/8/09
to Google-We...@googlegroups.com


I also hava same problem with gwt-FABridge
My code from example demo as follow:
the demo is right.
but I change the code
 swfWidget = new SWFABridgeWidget("app.swf",400,400,"PlayFLV");
as
 swfWidget = new SWFABridgeWidget("PlayFLV.swf",400,400,"PlayFLV");
at BridgeObject object =swfWidget.root()  occur the exception:

[ERROR] Uncaught exception escaped
com.google.gwt.core.client.JavaScriptException: (TypeError):
$wnd.FABridge[bridgeName] has no properties
 fileName: jar:file:/root/gwt-flex/gwt-fabridge/gwt-fabridge.jar!/org/
argunet/gwt/fabridge/client/SWFABridgeWidget.java
 lineNumber: 99
 stack: ()@jar:file:/root/gwt-flex/gwt-fabridge/gwt-fabridge.jar!/org/
argunet/gwt/fabridge/client/SWFABridgeWidget.java:99
static void com.google.gwt.user.client.DOM.dispatchEvent
(com.google.gwt.user.client.Event,com.google.gwt.user.client.Element,com.google.gwt.user.client.EventListener)
([object Event],[object HTMLButtonElement],[object
gwt_nativewrapper_class])@:0
([object Event])@jar:file:/usr/eclipse/gwt-linux-1.5.2/gwt-user.jar!/
com/google/gwt/user/client/impl/DOMImplStandard.java:197
@:0

       at org.argunet.gwt.fabridge.client.SWFABridgeWidget.getBridgeRoot
(Native Method)
       at org.argunet.gwt.fabridge.client.SWFABridgeWidget.root
(SWFABridgeWidget.java:87)
       at com.google.client.HelloGWT$2.onClick(HelloGWT.java:24)
       at com.google.gwt.user.client.ui.ClickListenerCollection.fireClick
(ClickListenerCollection.java:34)
       at com.google.gwt.user.client.ui.FocusWidget.onBrowserEvent
(FocusWidget.java:102)
       at com.google.gwt.user.client.DOM.dispatchEventImpl(DOM.java:1308)
       at com.google.gwt.user.client.DOM.dispatchEventAndCatch(DOM.java:
1287)
       at com.google.gwt.user.client.DOM.dispatchEvent(DOM.java:1255)


I don't know where is wrong?
==================================================================
package com.google.client;
import org.argunet.gwt.fabridge.client.SWFABridgeWidget;
import org.argunet.gwt.fabridge.client.bridge.BridgeObject;
import org.argunet.gwt.fabridge.client.events.IInitializationListener;
import com.google.gwt.core.client.EntryPoint;
import com.google.gwt.user.client.Window;
import com.google.gwt.user.client.ui.*;
public class HelloGWT implements EntryPoint , IInitializationListener
{
       private final Button addNewSwf = new Button("Add new SWF");
       private final Button setCheckBox = new Button("Set Checkbox
property");
       private SWFABridgeWidget swfWidget;
       public void onModuleLoad() {
               RootPanel.get().add(addNewSwf);
               RootPanel.get().add(setCheckBox);
               addNewSwf.addClickListener(new ClickListener() {
                       public void onClick(Widget arg0) {
                               swfWidget = new SWFABridgeWidget("app.swf",400,400,"PlayFLV");
                               swfWidget.addInitializationListener(HelloGWT.this);
                               RootPanel.get().add(swfWidget);
                       }
               });
               setCheckBox.addClickListener(new ClickListener() {
                       public void onClick(Widget arg0) {
                               BridgeObject object =swfWidget.root();
                               Window.alert("getObject");
                       }
               });
       }
       public void onInitialization() {
               Window.alert("hello");
Reply all
Reply to author
Forward
0 new messages