3 Replies Latest reply on Jul 19, 2011 11:24 PM by aaronkondziela

    ScriptUI's Window mousemove event not fired in CS5 with swf

    Anastasiy Safari Level 1

      Hi!

       

      I'm creating a ScriptUI Window and loading an swf file inside of it. Then I'm trying to listen to mousemove event with w.addEventListener('mousemove'...) as it is written in ScriptUI documentation. In Photoshop CS3 and CS4 all was working perfectly. Now it seems the mousemove event is not fired! I can still catch the event inside swf, of course, but I can't do it with ScriptUI in Photoshop CS5.

       

      I need to catch it from Window object to make it possible to move that window with mouse. My code is included. It's actually, a common code block proposed by documentation.

      Is something changed in CS5 comparing to the previous versions of Photoshop?

       

      // bootstrapping code for running a SWF
      $.evalSWF = function( swfFile )
      {
          if( swfFile.exists )
          {
              var btScript = 'var res = "palette{ properties: { resizeable: false, maximizeButton: false,  borderless:true }, fp: FlashPlayer{ preferredSize: [' + width + ', ' + height + '] } }";\n';
              btScript += "var w = null; w = new Window ( res ); \
                              w.opacity = 1.0; \
                  w.init = function() \
                  { \
                      try \
                      { \
                          this.fp.ExtendScript_init = function( initScript ) { return eval( initScript ); }\n\
                          this.fp.loadMovie ('" + swfFile + "'); \
                          w.addEventListener ('mousemove', function(event) { alert('!'); }, false);  \  // doesn' work
                      } \
                      catch (e) \
                      { \
                          alert ('Load Movie function failed: ' + e); \
                      } \
                  } \
                  w.onResize = function() \
                  {\
                      if( this.size != this.fp.size )\
                          this.fp.size = this.size;\
                  }\
                  w.margins = [0,0,0,0]; \
                  w.init(); \
                  w.addEventListener ('mousemove', function(event) { alert('!'); }, false);  \  //doesn't work either
                  w.show();";

       

              var bt = new BridgeTalk;
              bt.target = BridgeTalk.appSpecifier;
              bt.body = btScript;
              bt.onError = function(msg)
              {
                  alert( "ExtendScript_start: " + msg.body );
              }
              if( BridgeTalk.appName == "photoshop" )
                  bt.send( 60 * 5 );    // send the message synchronously and wait for max. 5 minutes.
              else   
                  bt.send();        // send the message asynchronously
          }
      }

       

      var root = File( BridgeTalk.getAppPath( BridgeTalk.appSpecifier ) ).parent;
      if( BridgeTalk.appName == "illustrator" )
          root = root.parent.parent.parent;
      root += "/Plug-Ins/Panels";
      var swfFile = new File( root + "/" + project + "/" + "main.swf" );
      var resolvedFile = swfFile.resolve();
      if( resolvedFile != null )
          swfFile = resolvedFile;
      if( !swfFile.exists )
          alert( swfFile + " does not exist"  );
      else
          $.evalSWF(swfFile);

       

       

       

      Thank you!

        • 1. Re: ScriptUI's Window mousemove event not fired in CS5 with swf
          taravasya Level 1

          In AE I have the same trouble. More! I noticed that the addEventListener does not work in the x64-bit applications. AE and Photoshop. For example, in Illustrator or Bridge this function works without any problems. In AfterEffects, I added a FlashPlayer on a custom panel, and insert addEventListener

          var flsMv = File(File($.fileName).parent.parent.absoluteURI + "/ScriptUI Panels/BoxBlurFade3.swf");
          myFLPL = AEPanel.add("FlashPlayer", [20, 20, 80, 80 ], flsMv);
          myFLPL .addEventListener ('click', onScriptButtonClick)

          function onScriptButtonClick()
          {
          var scriptFile = File(File($.fileName).parent.parent.absoluteURI + "/Change Render Locations.jsx");
          scriptFile.open();
          eval(scriptFile.read());
          scriptFile.close();
          }

           

          As a result, a click is triggered only at the very-very edge of FlashPlayer. And at the SWF, it just does not respond to clicks or the movement of the mouse.

          Someone knows how can we fix this bug

          • 2. Re: ScriptUI's Window mousemove event not fired in CS5 with swf
            Michael L Hale Level 5

            Yes, it looks like eventListeners don't work on the ScriptUI window itself in CS5. They do work on controls in the dialog. I have filed a bug report.

            • 3. Re: ScriptUI's Window mousemove event not fired in CS5 with swf
              aaronkondziela

              I also have this issue, in After Effects CS5.5 on Windos 7 64-bit. I'm not using a swf, but just a basic script in the ScriptUI Panel folder. Bug filed with included code sample to demonstrate the failure, in case it's helpful.

               

              ******BUG******
              Concise problem statement: Running on Windows Enterprise x64, events are not sent to the default ScriptUI Panel object. I have not verified that they do work under x86 32-bit windows, but users in the forum thread mentioned below report that this only affects 64-bit windows.

               

              Steps to reproduce bug:

               

              Create a script in the "Scripts/ScriptUI Panels" folder:

               

              var myPanel = createUI(this);

               

              function createUI(thisObj) {
              var win = (thisObj instanceof Panel) ? thisObj : new Window('palette', 'test', [100, 100, 300, 300]);
              win.margins = [10,10,10,10];
              win.alignChildren = ['left','bottom'];
              win.orientation = 'column';

               

              // Note, the button onClick events work fine
              var btnAdj = win.add('button', undefined, 'Create Matched Adj Layer');
              btnAdj.onClick = createAdj;
              var btnCount = win.add('button', undefined, 'Count Layers in Comps');
              btnCount.onClick = countLayers;

               

              // Broken events in CS5 x64??
              win.addEventListener('show', win.layout.layout);
              win.addEventListener('resize', win.layout.resize);
              win.addEventListener('click', function(){alert('clicked','clicked')} );

               

              // Required to work around bug, or else layout is never triggered; no events?
              // win.layout.layout();

              return win;
              }

               

              function countLayers() {
              alert('count','count');
              }

               

              function createAdj() {
              alert('count','count');
              }

               

              Results: Panel children controls do not draw because layout event doesn't fire. Resize and click don't work.

               

              Expected results: layout, resize and clicks should run registered event handlers