Search code examples
flashdialogjsflsuppress

JSFL: Suppressing/auto clicking on Dialog boxes


var tmpDoc = fl.createDocument();
/*..some logic...*/
tmpDoc.addItem({x:0,y:0},item);

My JSFL has the above code.
And on the 3rd line, I get a dialog box :
which has title : "Resolve library conflict"
two radio button options : "replace","dont replace"
two buttons : "ok","cancel"

Due to this dialog box, I have to manually monitor
the script execution and click on a button.

I want to either :
1. Suppress these kind of dialog boxex altogether.
2. or programatically provide a default option to these kind of dialogs.

How do I do it with JSFL?


Solution

  • You can try to check if the item exists before adding it to the library using library's itemExists() function:

    var doc = fl.getDocumentDOM();
    var lib = doc.library;
    //check if the item already exists first, if so, keep count of symbols with the same name, append random, etc.
    if(!lib.itemExists('item')) lib.addNewItem('movie clip','item');
    else                        lib.addNewItem('movie clip','item'+Math.random());
    

    HTH