2 Replies Latest reply on Jan 27, 2011 3:44 PM by darrendb

    Programatically Responding to the Replace Existing Item dialog in JSFL

    jelaplan Level 1
      JSFL includes a nice command named addItemToDocument. This allows the script to add components from the component panel to the stage (and library). If the component already appears on stage and the addition is newer than the version on stage, a dialog appears with the question 'One or More library items already exist in the document.' That is a rather inconvient happening for automating this task. My main goal is to update the components in many files after I update a component. I don't want to manually respond to that dialog.

      Any thoughts on programatically answering that dialog?
        • 1. Re: Programatically Responding to the Replace Existing Item dialog in JSFL
          darrendb Level 1

          I am having a very simliar (if not the same) issue. I have written a JSFL script to loop through all the symbols in the library (only those of type=="movie clip" and with linkageExportForAS=true) and one at a time add them to the stage. At the bottom of the loop i do a selectAll() and deleteSelection() to clear the stage before moving on the the next symbol. When i run the script, it goes through the first 35 mc's just fine, but hits a snag on a particular symbol. When it snags, i get the warning/prompt "One or more library items already exist in the document." Normally this only occurs when you are pasting from one document/library to another. In this case, there is only one .fla open. I'm simply adding from the library to the stage. I would love to know what is happening, and why. I'd be happy not knowing but being able to handle this automatically, supress the dialog, auto select a choice, something to keep the script running. I'm not worried about replacing the symbol or not, as I know it isn't a new symbol, its just seems to be a bug. Maybe there is something wrong with the symbol, but I'm not the "owner" of the .fla, I'm just exporting PNG's of each keyframe of each symbol that has a "states" layer. So fixing the symbol isn't really an ideal solution. Maybe i can just catch the error, write an error file, and move on.

          • 2. Re: Programatically Responding to the Replace Existing Item dialog in JSFL
            darrendb Level 1

            So, for any other poor chumps out there with the same problem, here's how i worked around it. This worked for my usage but probably wont for all cases... As I am looping through all items in the library, after i sort out the ones i want (movieclips with linkage) i create a duplicate symbol in the library, and give it a unique name. the duplicate method automatically appends a " copy", but as many unorganized libraries have symbols with similar names, i renamed it with a suffix of "_jsfl_copy". In addition, since the linkage was important to me, and duplicating an item does not copy the linkage values, I also had to manually turn linkage on and copy the values from the original item to the duplicated item. then i was able to add all the items to the stage without that prompt halting my jsfl script. Of course I removed the duplicate item at the bottom of my loop after i was done with it.