Creative COW SIGN IN :: SPONSORS :: ADVERTISING :: ABOUT US :: CONTACT US :: FAQ
Creative COW's LinkedIn GroupCreative COW's Facebook PageCreative COW on TwitterCreative COW's Google+ PageCreative COW on YouTube
ADOBE AFTER EFFECTS:HomeForumBasicsExpressionsTutorialsPodcastsAE TechniquesCreative Cloud DebateFAQ

ScriptUI problem

COW Forums : Adobe After Effects Expressions

<< PREVIOUS   •   FAQ   •   VIEW ALL   •   PRINT   •   NEXT >>
Share on Facebook
Mateo MazziniScriptUI problem
by on Dec 23, 2012 at 7:53:16 pm

I'm new to scripting for after effects. I have already done a script that works fine, but now I want to make it dockable.
I search, read, and practice but the code that supposedly works, does not for me.
Does anybody know what I'm doing wrong?

thanks!

function createUI(thisObj){
var ventana = (thisObj instanceof Panel) ? thisObj : new Window("palette", "mi Script", undefined, {resizeable:true});
var grupoTexto1=ventana.add("group");
grupoTexto1.add("statictext,undefined,"Nro de Layers");
var nLayers=grupoTexto1.add("edittext",undefined,"1");
nLayers.characters=4;
nLayers.active=true;
}
createUI(this);


Return to posts index
Reply   Like  


Xavier GomezRe: ScriptUI problem
by on Dec 24, 2012 at 12:49:22 pm

I'm no expert, there is a very nice guide here: http://www.kahrel.plus.com/indesign/scriptui-2-0.pdf, but here are few comments:

in line 4, replace: "statictext by: "statictext".

At this point your function createUI builds a palette but doesnt show it nor return it. You need a Window.show() somewhere. That's the strict minimum, but there are other options (see the guide for that).

1- You can either write a line

ventana.show();

just before the end of your function. In that case, when you call createUI(thisObj), it will build then automatically show the palette.
But you will be in trouble accessing the palette data (for instance: nLayers).

2- or you can make the function return the whole palette. Instead of vendana.show() you write:

return(ventana);

In that case, to build and show the palette you write

var ventana = createUI(this);
ventana.show();

now ventana is a Window object in your script and you can access its properties. Actually since you didnt explicitely name the palette properties it's not so easy. To read the nLayers value you'll have to do:

var x = parseInt(vendana.children[0].children[1].text);
x = (isNaN(x) || x<1) ? 1 : x; //etc

To make things easier you can name the palette properties upon creation (the ones that you will need to access), like this:

function createUI(thisObj)
{
var ventana = (thisObj instanceof Panel) ? thisObj : new Window("palette", "mi Script", undefined, {resizeable:true});

var grupoTexto1=ventana.add("group");
grupoTexto1.add("statictext",undefined,"Nro de Layers");
var nLayers=grupoTexto1.add("edittext",undefined,"1");
nLayers.characters=4; nLayers.active=true;

ventana.nLayers = nLayers;

ventana.nLayers.onChange = function()
{
var x=parseInt(this.text);
this.text = (isNaN(x) || x&lt;1) ? 1 : x;
}

return(ventana);
}

var pal = createUI(this);
pal.show();

var x = parseInt(pal.nLayers.text);//etc


Return to posts index
Reply   Like  
+1

Mateo MazziniRe: ScriptUI problem
by on Dec 25, 2012 at 7:07:28 pm

Finally I made it Work! thanks a lot Xavier, your method worked just fine. The only thing I had to change was the ".show()" method, wich doesn't work with ScriptUI panels in After Effects. There is a diference (from what i had noticed) between the script panels and the ScriptUI panels in After Effects: if i left "undefined" in the alignment of an element in the panel, it shows up just fine. But, the only way I could make appear a button, a text, or whatever in a ScriptUI panel, was giving to After Effects Specific coordinates... otherwise it just won't work.

Once again, thanks for your reply.. I leave you with the code that worked for me... hope it helps some one else...

(as always, I have to excuse me for my english... is not my native tong)

function createUI(thisObj)
{
var ventana = (thisObj instanceof Panel) ? thisObj : new Window("palette", "mi Script", [100, 100, 300, 300], {resizeable:true});

ventana.add("statictext",[10, 10, 80, 30],"Nro de Layers");
var nLayers=ventana.add("edittext",[90, 10, 180, 30],"1");
nLayers.active=true;
return(ventana);
}

var pal = createUI(this);
pal;


Matz


Return to posts index
Reply   Like  

<< PREVIOUS   •   VIEW ALL   •   PRINT   •   NEXT >>
Share on Facebook


FORUMSTUTORIALSFEATURESVIDEOSPODCASTSEVENTSSERVICESNEWSLETTERNEWSBLOGS

Creative COW LinkedIn Group Creative COW Facebook Page Creative COW on Twitter
© 2014 CreativeCOW.net All rights are reserved. - Privacy Policy

[Top]