ScriptUI problem

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?

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:

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)