5 Replies Latest reply on Feb 23, 2011 10:14 PM by dposluns

    PS CS4 CSXSLibrary: "CSXSInterface.instance" always null

    renderhjs2 Level 1

      I was referred to this sub section of the adobe forums for this question:


      I want:

      Start creating my own Photoshop CS4 SWF panel coded with the FlexSDK in FlashDevelop (pure AS3, no flex).


      I have:

      • FlexSDK & FlashDevelop
      • CSXSLibrary-2.0-sdk-3.4.swc
      • Photoshop CS4



      • whenever I try compile or test my compiled SWF movie in Photoshop I get a null object for the CSXSInterface.instance. This object however is supposed to be the bridge between AS3 and the Photoshop JSX interaction.


      here is a simplified code that causes this error:

           import com.adobe.csxs.types.*;
           import com.adobe.csxs.events.*;
           import com.adobe.csxs.core.CSXSInterface;
           import flash.display.Sprite;
           import flash.events.Event;
           public class Main extends Sprite 
                public function Main():void 
                     if (stage) init();
                     else addEventListener(Event.ADDED_TO_STAGE, init);
                private function init(e:Event = null):void {
                     CSXSInterface.instance.addEventListener(StateChangeEvent.WINDOW_OPEN, creationComplete);
                private function creationComplete(e:Event):void {

      Once I compile the SWF and have it run in the debug Flash Player I get a error message:

      [Fault] exception, information=TypeError: Error #1009: Cannot access a property or method of a null object reference.

      And whenever I test the SWF as a Photoshop panel (by copying the SWF file in the plugin../panel folder) I get null objects whenever I try to access it which blocks any associated actions (events, triggers,...).

      I am using CSXSLibrary-2.0-sdk-3.4.swc in combination with Photoshop CS4. Is that library perhaps not suited for CS4? Do I need a older library and if so where can I download it. Most of the libraries seem to be rather difficult to find on the internet anyway - which is a big drag for me.

      The SWC library itself however is just fine added to the library as I can even access the CSXSInterface class itself booth while coding and at runtime. Just the .instance or getInstance() singleton returns always NULL.


      Any insight or input would be greatly appriciated

        • 1. Re: PS CS4 CSXSLibrary: "CSXSInterface.instance" always null
          Harbs. Level 6

          In your original post, I don't think you mentioned CS4...


          CS SDK is CS5 only. Are your using the CS SDK libraries, or the CS4 specific libraries?


          I don't know very much about CS4 Photoshop panels, but I'm pretty sure that the CS5 libraries are incompatible with what you guys had for CS4...


          Good luck,


          • 2. Re: PS CS4 CSXSLibrary: "CSXSInterface.instance" always null
            renderhjs2 Level 1

            first of all thanks Harbs to take the time to respond in booth threads,


            Just to be clear: I haven't used yet the SDK zip and its libraries that are referred to on the adobe developer page. Instead I am referring to this:


            with the Photoshop Panel Developer's Guide Win (ZIP, 10.9MB)

            http://download.macromedia.com/pub/developer/photoshop/sdk/photoshop_panel_developers_guid e_cs5_win.zip


            And I followed all their instructions on the sample tuturials but I am still getting NULL for the .instance singleton booth running within the debug flash player and within Photoshop CS4. JSX scripts alone seem to work so does the Adobe Scripting toolkit when I link it to Photoshop CS4, but like I said I don't have any luck with SWF panels.


            Isn't there a spot where I can download all the required files for Photoshop CS4. Because as far as I know it all started with Photoshop CS4 and it should be still supported. I am stuck with CS4 so is the company I work at so it makes only sense for me to start developing for Photoshop CS4.


            Most of the tutorials and examples I found on the internet targeted CS4 but they just mentioned a CSXSLibrary...swc. Never did they provided a swc download so I am kind of stuck here, as I don't know if the problem is the CSXSLibrary-2.0-sdk-3.4.swc library that I am using or something else along the road.

            • 3. Re: PS CS4 CSXSLibrary: "CSXSInterface.instance" always null
              renderhjs2 Level 1

              I finally found a older SWC library ("CSXSLibrary.swc") at:


              within the ZIP:



              And my panel seems to finally work with that under Photoshop CS4 which is awesome .I just wish Adobe would be more clear on this whole Panel SWF extending stuff. Its really tricky to get your hands on the CSXSLibrary.swc file for CS4 or any of the older ones.


              Maybe within a year or 2 when i get my hands on CS5 I might start looking into the new SDK but for now this works for me as my working environment & people I share scripts with don't use CS5 yet either.

              • 4. Re: PS CS4 CSXSLibrary: "CSXSInterface.instance" always null

                I'm having the exact same problem, attempting to make a panel in Flash CS4 to run in Photoshop CS4.


                I've tried CSXSLibrary-2.0-sdk-3.4.swc and CSXSLibrary-2.0-sdk-3.3.swc in the SDK, and the separate CSXSLibrary.swc that's been linked to. None of them work; CSXSInterface.instance is always null when my ActionScript runs in Photoshop.


                All I'm doing right now is creating a single Button component, with a script that attempts to run a test function in Photoshop.


                What's interesting is I can put the ShortcutButtons.jsx and ShortcutButtons.swf from the SDK into Plug-ins/Panels and that works just fine. My JavaScript is essentially the same:


                function TestFn()
                     alert("Hello, world!");


                And my ActionScript is as follows:


                import com.adobe.csxs.core.CSXSInterface;
                var btnTest = (root as MovieClip).btnTest;
                btnTest.addEventListener("click", testFn);
                function testFn(event:MouseEvent)


                (I've put other test code in the testFn() that confirms that the click event is registered correctly.)


                I link the CSXSLibrary.swc in the "Library path" section of the ActionScript 3.0 settings, and I know it's being linked to because the size of my SWF balloons from 20 kB to anywhere from 50 to 300 kB depending on which library I'm trying.


                What am I missing here...?




                • 5. Re: PS CS4 CSXSLibrary: "CSXSInterface.instance" always null
                  dposluns Level 1

                  Ok, I found another tutorial that solved my problem in the comments. Basically, I had to add the following lines to the top of my script (before the CSXSInterface import):


                  import mx.core.*
                  var resourceManagerImpl:Object = flash.system.ApplicationDomain.currentDomain.getDefinition("mx.resources::ResourceManagerImpl");
                  mx.core.Singleton.registerClass("mx.resources::IResourceManager", Class(resourceManagerImpl));


                  Then I needed to change the Publish Settings so that Local Playback Security was set to "Access network only".


                  Then, using the version of CSXSLibrary.swc that's linked to in a previous post in this thread, I was finally able to run JavaScript Photoshop-side.


                  Phew! What an ordeal just to get a little scripting going.