CSXSLibrary works on CS5 but not in CS4

Anyone, especially newbies, asking for help with Photoshop Scripting and Photoshop Automation - as opposed to those contributing to discussion about an aspect of Photoshop Scripting

Moderators: Tom, Kukurykus

d3mac123

CSXSLibrary works on CS5 but not in CS4

Post by d3mac123 »

I read all other topics about this issue but none of them have worked in my case. Hope you can help me here.

My project runs perfectly on CS5. It was built on Flash Builder CS4, using CSXSLibrary-2.0.swc. My code calls:
Code: Select allimport com.adobe.csxs.core.CSXSInterface;
import com.adobe.csxs.types.*;
import com.adobe.csxs.types.SyncRequestResult;


then I added the following code, from this forum:
Code: Select all//DO NOT REMOVE
         // needs to enable Photoshop sending commands
         // host var and const
         public var hostMajorVersion:Number = -1;
         public var hostMinorVersion:Number = -1;
         public var hostFixVersion:Number = -1;
         public const photoshopCS4Version:Number = 11;
         
         
         
         public function getPSVersion():void{
            var reqResult:SyncRequestResult = CSXSInterface.instance.evalScript("getVersion");
            if (SyncRequestResult.COMPLETE == reqResult.status) {
               var versionString:String = reqResult.data.version;
               var versionArray:Array = versionString.split(".");
               if (versionArray.length >= 1) {
                  hostMajorVersion = Number(versionArray[0]);
               }
               if (versionArray.length >= 2) {
                  hostMinorVersion = Number(versionArray[1]);
               }
               if (versionArray.length >= 3) {
                  hostFixVersion = Number(versionArray[2]);
               }
               //projMedia.text = versionString;
            }
         }


lastly, I coded the callbacks:
Code: Select all         public function init():void{   
            getPSVersion();
            CSXSInterface.instance.evalScript("PhotoshopPersistent");
            CSXSInterface.instance.evalScript("loadConfig");
            CSXSInterface.instance.evalScript("PhotoshopRegisterEvent", charToInteger("slct").toString());
            // conditional for CS4, CS5 PhotoshopCallback
            if (hostMajorVersion == photoshopCS4Version) {
               ExternalInterface.addCallback("PhotoshopCallback", PhotoshopCallback);
            } else {
               ExternalInterface.addCallback("PhotoshopCallback" + CSXSInterface.instance.getExtensionId(), PhotoshopCallback);
            }
            
         }
         public function charToInteger(keyword:String):Number{
            var value:Number;
            value  = keyword.charCodeAt(0) * 256 * 256 * 256;
            value += keyword.charCodeAt(1) * 256 * 256;
            value += keyword.charCodeAt(2) * 256;
            value += keyword.charCodeAt(3);
            return value;
         }
         
         
         public function PhotoshopCallback(eventID:Number, descID:Number):void{
            var reqResult:SyncRequestResult = CSXSInterface.instance.evalScript("getCurrentTool");
            if (SyncRequestResult.COMPLETE == reqResult.status) {
               var tTool:String = reqResult.data.tool;
               var tDoc:String = reqResult.data.doc;
               //versNum.text = String(tTool);
            }
            if (lastDoc == tDoc) {

            } else {

               lastTool = tTool;
               lastDoc = tDoc;
               getPSProjXML();
            }
            
         }


I tried to replace the CSXSLibrary by an old one mentioned in the forums but it didn't work either. Ideas?
Thanks again,
Alex