We were unable to load Disqus. If you are a moderator please see our troubleshooting guide.
But about that JSON parsing. lots of panels now use JSON files to parse localization instead of a properties file. Am i getting the context wrong about what you said in the end of the article?
quote:
Mind you: I’ve experimented importing a JSON library in the ExtendScript code (which doesn’t natively support it) and tried to var obj=JSON.parse(o); to no avail. Apparently the code is OK as it is, without it.
Is there a way to do this other way around? I would like to call a function using jquery or java and use a function in my js file?
For now i used a dirty trick. Im check to see what title the html doc is than i can call a function from within th js file just after its initilazed... clever right ;)
I need to do this check because ive implemented locase in the panel. ang what was that difficult to setup. Ive been busy with that for 2 full days! But im no coder and probably my code is very dirty.
I even found a trick to install multiple languages without downloading photoshop again :) I went digging in an old kpg file i had. All language packs are inside :)
Hi Davide,
First of all thank you for all this helpful articles!!! I would like to know one thing. How can I pass the result of csInterface.evalScript function to a variable outside of this function? Something like this for example...
(function()
{
'use strict';
var csInterface = new CSInterface();
var psDocumentsLength; //1//
function init()
{
themeManager.init();
$(document).ready(function()
{
check_PSDocumentsLength();
alert(psDocumentsLength); //4//
});
};
init();
function check_PSDocumentsLength() //2//
{
var chosenFunction = 'checkDocumentsLength()';
csInterface.evalScript(chosenFunction, function(result)
{
psDocumentsLength = result; //3//
});
};
}());
Because I have try several things but variable returns as undefined!!!
Thank you for your time!!!
Hi Davide,
Thank you for your great article.
Do you know how can I transfer data include Chinese characters from JS to JSX?
Here is my result .
JS "你好"--->JSON Object---> JSX "??????"
Thank you for any help.
Hi Davide,
How can I transfer data from index.html to JSX. In your example object defined in main.js.
Thanks a lot.
Hi Cihan, data in the index.html can (and must) be gotten by the JS. There are several ways to do so, e.g. if you have an input of type text and id equals to "foo", you can document.getElementById('foo').value.
Hi Davide,
as far as I could evaluate using "JSON.parse(...)" on the ExtendScript side does not work because a parameter passed to the ExtendScript from the Panel that is a "stringified" representation of an object _is_ already an object on the ExtendScript side. So, calling "JSON.parse(param)" will fail (assuming you have included "json2" in the VM executing the ExtendScript). Instead it seems to be sufficient to just refer to "param.property" and everything is alright. The same thing, BTW, happens when passing custom events from ExtendScript to the panel, i.e. the event having a data property which is populated with an object stringified on the ExtendScript side.
How do I pass a json object?
you can pass json back and forth by 'stringifying' your obj.
jamJSON works in extendscript
Hi! I wanted to create a slider in custom panel which changes the for eg opacity of the current layer.
Here is what I used in HTML5
Here is the javascript function
$._ext_OPACITY={
run : function() {
app.activeDocument.activeLayer.opacity = 50;
},
};
Now can you please tell me how to link that HTML slider with this function so that user can change the opacity using the slider. Thanks alot.
Hi Davide! Thanks for these tutorials. I'm having a pretty significant issue though. The boilerplate you recommend isn't actually working. I started a project from it, and without adjusting a thing, I launched Illustrator and clicked the main button that was supposed to run the ExtendScript routine, but nothing happens.
Are you aware of this issue? Have I missed something? Or has there been a change to CC that broke the boilerplate, that you're aware of?
Thanks for any help with this!
Hello Aaron,
have you tried these ones (always provided by David Deraedt)?
I haven't Illustrator so I'm afraid I can't test - but as far as I know David's repo on GitHub should be app-agnostic.
Tried using part of this article in a something different. That function with "result" as parameter keeps returning undefined. That result is not declared anyway if im correct. How can your exaomple even run getDocName() script, there is no JSX extension nor is there a path where to load it from?