suspendHistory() not working...

General Discussion of Scripting for Flex, Flash & CS SDK

Moderators: Tom, Kukurykus

undavide

suspendHistory() not working...

Post by undavide »

Hello,
I can't make the suspendHistory() method work in ActionScript.

Code: Select allapp.activeDocument.suspendHistory("PRIVATE", "app.activeDocument.activeLayer.duplicate()");

fires "Error: General Photoshop error occurred. This functionality may not be available in this version of Photoshop."

The second parameter, according to the documentation, is a "JavascriptString:String - A string of JavaScript code to execute during the suspension of history".
Has anyone been able to make it work?
Thanks,

Davide
Mike Hale

suspendHistory() not working...

Post by Mike Hale »

This is just a guess, I have not used suspendHistory in actionscript.

But in extendscript it is more common to call a user function that would have used multi-history states than a DOM method that only uses one state. Have you tried wrapping the DOM method in a user function and calling that function instead?
undavide

suspendHistory() not working...

Post by undavide »

Hello Mike,
it was just for showing that a simple call is not recognized - even an alert("Hello World") leads to the same error.
By the way, it's would be not clear even *where* to put a function that would be called by the suspendHistory() method.
I mean:

Code: Select allapp.activeDocument.suspendHistory("PRIVATE", "myFunction()");

Where is myFunction supposed to be? In the JSX? No, it doesn't work. I've created a new project named "TEST" in Extension Builder (with the two buttons that it adds as the default options).
In the TESTPhotoshop.as:

Code: Select allpublic static function run():void
{
   var app:Application = Photoshop.app;
   app.activeDocument.activeLayer.duplicate();
   app.activeDocument.suspendHistory("PRIVATE", "jsxFunction()");
}


and I've added an alert("Hello") in the jsxFunction() within the TEST.jsx
Pressing the Run PS Code leads to the usual crash.

So it's kind of puzzling...
Davide
txuku

suspendHistory() not working...

Post by txuku »

Hello undavide

Code: Select allapp.activeDocument.suspendHistory("PRIVATE", "myFunction()");

It works well for me with CS4 - not with CS2.
undavide

suspendHistory() not working...

Post by undavide »

txuku wrote:It works well for me with CS4 - not with CS2.

Hello,
do you mean that it works within a CS-SDK project for CS4/5 in ActionScript code?
Since you mention CS2, you're possibly talking about ExtendScript code... this I know - my problem is that the suspendHistory() method isn't working as documented here.
If you've been successful, could you please share a simple FlashBuilder project?
Thanks,

Davide
txuku

suspendHistory() not working...

Post by txuku »

Excuse me undavide !

I had not very well understood - I know nothing about ActionScript
undavide

suspendHistory() not working...

Post by undavide »

txuku wrote:Excuse me undavide !
I had not very well understood - I know nothing about ActionScript

No problem
It's been officially recognized as a bug in the Adobe Forum.
Looks like there are still many problems around in CS SDK...
Thanks anyway

Davide

PS
By the way, it's possible to bounce, in the middle of an AS3 function to JS code (within an embedded JSX) and run there a suspendHistory() method, that launch a function back in AS3. Doesn't help in keeping the code clear, but at least it works!