3 Replies Latest reply on Jun 29, 2012 3:57 PM by DBarranca

    How to detach an ExternalInterface registered Event?

    DBarranca Level 4

      Hello,

      following EB documentation, I'm registering for a Photoshop event this way:

       

      DocumentWatcherPS.as

       

      private static const COUNTER:int = Photoshop.app.stringIDToTypeID( "countAdd" );
      
      public static function addPSSpecificCase():void
      {
      CSXSInterface.instance.evalScript("PhotoshopRegisterEvent", COUNTER.toString());
      ExternalInterface.addCallback("PhotoshopCallback" + CSXSInterface.getInstance().getExtensionId(), myPhotoshopCallback)
      }
      

       

      then I would like to remove the listener:

       

      public static function detach():void 
      {
        // ??
      }
      

       

       

      I'll be glad if someone could help me filling the function with some useful code

      Thanks in advance

       

      Davide

        • 1. Re: How to detach an ExternalInterface registered Event?
          DBarranca Level 4

          Undocumented in Extension Builder help, AFAIK, I had to look back into the Photoshop Panel Developer's Guide for CS4 to get it finally.

          Nicely, where there's a PhotoshopRegisterEvent, they've provided a PhotoshopUnRegisterEvent(). Phew!

           

          Davide

          1 person found this helpful
          • 2. Re: How to detach an ExternalInterface registered Event?
            lukychan

            I just wonder if you make it working (and how)?

            I am using PhotoshopUnRegisterEvent but  always get 'failed" response and I can't unregister events

            • 3. Re: How to detach an ExternalInterface registered Event?
              DBarranca Level 4

              I resuscitate an old post because (weird to say it) I've run into the very same problem again (how to detach an event), recalling that I had found the solution in the past - so instead to thank myself for the suggestion, here it is for lukychan the code - working for me.

              If the DocumentWatcherPS class I've this listener:

               

              public function start():void {
                   CSXSInterface.instance.evalScript("PhotoshopRegisterEvent", model.MAKE_INT); 
                   ExternalInterface.addCallback("PhotoshopCallback" + CSXSInterface.getInstance().getExtensionId(), myPhotoshopCallback); 
              }
              

               

              where model.MAKE_INT in the AppModel class is:

               

              MAKE_INT:String = Photoshop.app.charIDToTypeID('Mk  ').toString();
              

               

              The detach function is as follows:

               

              public static function detach():void {
                   CSXSInterface.instance.evalScript("PhotoshopUnRegisterEvent", model.MAKE_INT);
                   trace("Detached"); // it works!
              }
              

               

              Hope this helps!

              Davide