Using JSFL, pulling items out of a library using libraryPath

2.1k Views Asked by At

I'm making a SWF panel to automate some file setup. I'm using the libraryPath JSFL command to point to some external libraries. How do I put an item from one of those external libraries onto the stage using JSFL?

I've tried:

fl.getDocumentDOM().library.addItemToDocument({x:0, y:0}, 'myItem');
2

There are 2 best solutions below

0
George Profenza On

Isn't the libraryPath to SWC files as in compiled flex like libraries, not visual components swc files?

If you want to add component swcs, use the componentPanel object:

fl.componentsPanel.addItemToDocument({x:0, y:200}, "User Interface", "Button"); 
0
Nicolas On

From Adobe's documentation :

var itemIndex = fl.getDocumentDOM().library.findItemIndex( "myItem" );
var theItem = fl.getDocumentDOM().library.items[itemIndex];
fl.getDocumentDOM().addItem( {x:0,y:0}, theItem );