1 Reply Latest reply on Aug 29, 2007 8:56 AM by SeanMichaelMiller

    FABridge: clicking a Flex button from javascript

    SeanMichaelMiller
      Using the FABRidge and Flex SDK 3 beta 1 I'm trying from javascript to click a button in a Flex app, to set up some automated tests.

      I can get the button, with FABridge.flash.root().getSubmitButton(), and using Firebug I can see the methods available to me and I can call some of them successfully, but I can't seem to call dispatchEvent("click") or dispatchEvent(Event.CLICK) -- I get a 1034 error in the FABridge.js callASMethod at line 322,

      retVal = this.target.invokeASMethod(objID, funcName, args);

      where objID is "1", funcName is "dispatchEvent", and args is "['click']".

      Any ideas of what I need to do differently would be very much appreciated. (Do I need to pass a Flash Event.CLICK from the javascript side, and if so, how do I do that?)

      Thanks,
      Sean.
        • 1. Re: FABridge: clicking a Flex button from javascript
          SeanMichaelMiller Level 1
          So what we needed to do was dispatch a MouseEvent(MouseEvent.CLICK). To get at that from javascript we added a method to our mx:Script in mxml:

          import flash.events.MouseEvent;

          public function getClick():MouseEvent {
          return new MouseEvent(MouseEvent.CLICK);
          }

          We then ended up calling

          submit = window.FABridge.flash.root().getSubmitButton();
          submit.dispatchEvent(window.FABridge.flash.root().getClick());

          in our javascript.