Flashadvisor logo
:: Desktop Shortcut
:: Flash Help
Advices from Experts

 Submit Here! · Link to Us · Newsletter · Tell a Friend ·

      Add Tutorial |

 

Advertise here










 

Google

Search WWW   
FlashAdvisor.com

 Home > Tutorials  > Dynamic Content

Flash Macro > Organizing Library using JSFL

Author: Saumitra Karandikar | Email


Advertisement


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:


//create organization folders
fl.getDocumentDOM().library.newFolder("Audio");
fl.getDocumentDOM().library.newFolder("Buttons");
fl.getDocumentDOM().library.newFolder("Graphics");
fl.getDocumentDOM().library.newFolder("Movie Clips");
fl.getDocumentDOM().library.newFolder("Miscellaneous");


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,

myItemType = myItem.itemType;
myItemName = myItem.name;


As obvious, the properties itemType and name are used to identify the type and name of the item in the library.

We use the library object method moveToFolder to move the library item from root to the desired folder as follows:

mylibrary.moveToFolder("Graphics", myItemName, true);


Download Source File

| 1 | 2 | 3 |

Rate This Tutorial :
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
  

Home | About Us | Contact Us | Feedback | Advertise with us

Best viewed in 800x600 resolution with Internet Explorer.

Site Developed and Hosted by  ethicsolutions.com
All rights reserved with FlashAdvisor

Flash is a registered trademark of Adobe Systems, Inc.

1 user online