Palette can't access active document
Hello !
I am working on a randomizer script for illustrator, and i am stubling on a problem.
I would like my script to be a palette, but when i change
new Window("dialog", ...)
to
new Window("palette", ...)
my script can no longer call app.activeDocument .
Here are the bits of code interesting :
#target illustrator
#targetengine "session"
var dialogUI = (function () {
var palette = new Window("palette", undefined, undefined, {closeButton: true, resizeable: true});
[...]
var apply = group_button.add("button", undefined, undefined, {name: "apply"});
apply.text = "apply";
apply.addEventListener("click",function(){
MyDoc = app.activeDocument;
MySelection = MyDoc.selection;
if(MySelection instanceof Array){
if(tab_selectionnee == tab_fill_colour){
random_background_color()
}
}
app.redraw()
})
palette.show();
}());
The error is where MyDoc = app.activeDocument; is, and MySelection = ... is never called
Does anyone have an idea on how to solve this ?
