Ultrashock Forums > Flash > ActionScript
[JSFL] Organizing library items

You are currently viewing our website as a guest which gives you limited access to forums, files and other resources.

Click here to join now for free, and start interacting with our members, download files and much more!

Click here if you are looking for our Flash files and other professional assets.
 
Post Reply | View first unread | Rate Thread Search this Thread | Thread Tools | Display Modes

#1
Bookmark and Share!
[JSFL] Organizing library items
Old 2008-08-08

A long time ago Nutrox posted a thread with details on he organizes his library items in Flash, which I set mine up similarly. I couldn't find the thread so I have to start a new one. Here is a jsfl script that I wrote that will create a folder structure:

lib
---- clips
---- bitmaps
---- fonts
---- media

Anytime you run the script it will put all your items in the correct folder. I didn't create a folder for "buttons" because I don't use them and prefer to use mc's. Also when you import a png, Flash creates a graphic symbol for the image. When you run the script it will delete that symbol since I haven't come across a time when it was needed. This is my first time working with jsfl so if my code is a bit sloppy please let me know how to optimize. I did run tests and it works fine and it does work correctly.

Code:
var dom = fl.getDocumentDOM();

if( dom == null || dom == undefined )
{
    alert( "Document Object is null and cannot be accessed" );
}
else
{
    createLibrary();
    cleanLibrary();
}

function createLibrary()
{
    dom.library.newFolder( "lib/bitmaps" );
    dom.library.newFolder( "lib/clips" );
    dom.library.newFolder( "lib/fonts" );
    dom.library.newFolder( "lib/media" );
}

function cleanLibrary()
{
    var libraryItems = dom.library.items;
    
    var i = libraryItems.length;
    
    while( i -- )
    {            
        if( libraryItems[ i ].itemType == "movie clip" )
        {
            dom.library.moveToFolder( "lib/clips", libraryItems[ i ].name, true );
        }
        else if( libraryItems[ i ].itemType == "bitmap"  )
        {
            dom.library.moveToFolder( "lib/bitmaps", libraryItems[ i ].name, true );
        }
        else if( libraryItems[ i ].itemType == "font" )
        {
            dom.library.moveToFolder( "lib/fonts", libraryItems[ i ].name, true );
        }
        else if( libraryItems[ i ].itemType == "sound" || libraryItems[ i ].itemType == "video" )
        {
            dom.library.moveToFolder( "lib/media", libraryItems[ i ].name, true );
        }
        else if( libraryItems[ i ].itemType == "graphic" )
        {
            dom.library.deleteItem( libraryItems[ i ].name );
        }
    }
}
I'm going to eat your brain and gain your knowledge.
postbit arrow 1 comment | 893 views postbit arrow Reply: with Quote   
Registered User
Isocase is offline
seperator
Posts: 1,411
2006-11-03
Age: 28
Isocase lives in United States
Isocase's Avatar
seperator

Ultrashock Member Comments:
Anik's Avatar Anik Anik is offline Super Moderator Anik lives in Argentina 27 Creative Assets 2008-08-08 #2 Old  
thanks for sharing isocase, ill test it later and let you know how it goes.
Reply With Quote  
Thread Tools
Display Modes Rate This Thread
Rate This Thread: