The Object we will use here is the Library object that represents the library of the currently open Flash file. So lets first create an instance of the same as follows:
//create an instance of library object
mylibrary = fl.getDocumentDOM().library;
Notice that Library Object is the child of the top level 'fl' or 'flash' object hhence is derived from the document DOM.
Next, we create the folders we need to put our items in. We do this by invoking the "newFolder" method for the library object as follows:
This will create the required 5 folders in the Library. These folders will be empty initially. The folders behave similar to windows. If they exist already, they are not deleted and recreated and any items within them remain intact.
Next we identify the items in the library and their count.
//get items in library in an Array
itemArray = mylibrary.items;
totalCount = itemArray.length;
The itemArray represents an Array of all items in the Library. Thus, the variable totalCount is the number of items in the Library.
Next we loop through the Library to check the type of each item. Depending the type of item we put the items in the respective folders that we created above. Thus,
We hope the information helped you. If you have any questions
or comments, please don't hesitate to post them on the
Forums section Submit your Tutorial at Click Here