Skip navigation
renderhjs2
Currently Being Moderated

PS CS4 CSXSLibrary: "CSXSInterface.instance" always null

Aug 30, 2010 5:10 AM

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

 

issues:

  • 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:

package 
{
     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

 
Replies
  • Currently Being Moderated
    Aug 30, 2010 9:58 AM   in reply to renderhjs2

    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,

    Harbs

     
    |
    Mark as:
  • Currently Being Moderated
    Feb 23, 2011 9:29 PM   in reply to renderhjs2

    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!");
         app.documents.add();
    }
    

     

    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)
    {
         CSXSInterface.instance.evalScript("TestFn");
    }
    

     

    (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...?

     

    Thanks,


    Dan.

     
    |
    Mark as:
  • Currently Being Moderated
    Feb 23, 2011 10:14 PM   in reply to dposluns

    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.

     

    Dan.

     
    |
    Mark as:

More Like This

  • Retrieving data ...

Bookmarked By (0)

Answers + Points = Status

  • 10 points awarded for Correct Answers
  • 5 points awarded for Helpful Answers
  • 10,000+ points
  • 1,001-10,000 points
  • 501-1,000 points
  • 5-500 points