Code:
// with two items in the library, "face" and "eye", select an instance of face on the stage and run this command:
var doc = fl.getDocumentDOM();
if (doc.selection.length == 1) {
var xPosition = 0;
var yPosition = 0;
var libraryName = doc.selection[0].libraryItem.name
doc.library.editItem(libraryName);
doc.library.addItemToDocument({x:xPosition , y:yPosition}, "eye");
doc.exitEditMode();
}
or, without having to select it first
Code:
var doc = fl.getDocumentDOM();
var xPosition = 0;
var yPosition = 0;
doc.library.editItem("face");
doc.library.addItemToDocument({x:xPosition , y:yPosition}, "eye");
doc.exitEditMode();