Flash, Web developer

Flash JSFL Script – Allow Smoothing on all Bitmaps in library

Provided by Mirko Sabljic, this JSFL command script allows you to set AllowSmoothing to all bitmaps in library. It’s pretty usefull thing if you decide to take that step with your bitmaps in Flash.

code is very simple, but I’ve never had found any good resource for JSFL variable and other definitions.
Anyway Mirko did wonderfull job – script is available via download here

Code :

var libItems = fl.getDocumentDOM().library.items;

for (i = 0; i < libItems.length; i++){
if(libItems[i].itemType == “bitmap”){
libItems[i].allowSmoothing = true;
libItems[i].compressionType = “lossless”;
}
}

to run the script you can go to Commands > Run Command and then browse for this JSFL

you can also copy this JSFL file to the
Flash_root_folder/en/First Run/Commands to get it in Commands menu

edit :

if you want to set images to JPEG Compression you can change line

libItems[i].compressionType = “lossless”;

with

libItems[i].compressionType = “photo”;
libItems[i].quality = 70; //specify custom quality if you want

About these ads
Standard

27 thoughts on “Flash JSFL Script – Allow Smoothing on all Bitmaps in library

  1. dude! you are a life-saver. I am the lead of a flash development team that works in HEAVY volumes of bitmaps that need to be scaled and this script is going to save us so much time. Thanks so much!

  2. thanx and thanks go to Mirko too

    please send me your work when you finish so I can possible feature it on few forums and sites

    good luck on your work !

  3. something like this is a little better, allowing you to turn smoothing back off, as well as only apply it to items that you have selected in the library:

    var promptVal = prompt(“Allow Smoothing? (1=Yes, 0=No)”, “1”);
    var theLibrary = fl.getDocumentDOM().library;
    var selectedItems = theLibrary.getSelectedItems();

    fl.outputPanel.clear();

    for(var itemIndex=0; itemIndex < selectedItems.length; itemIndex++){
    var theItem = selectedItems[itemIndex];
    theItem.allowSmoothing = (promptVal==”1″) ? (true) : (false);
    var itemName = theItem.name;

    var enableDisable = (promptVal==”1″) ? (“Enable”) : (“Disable”);
    var outputString = enableDisable + ” smoothing on: ” + itemName;
    fl.outputPanel.trace(outputString);
    }

    fl.outputPanel.trace(“Smoothing Complete!”);

  4. L says:

    cheers for the code man i used for some files with hundreds of bitmaps in Library so it saved me hours if not days. I removed the bit that sets compression as i prefer to do this in publish settings that apply for all so its easy to change that setting later when compressing the final swf.

    @Jeremy
    Why is it a problem to Allow Smoothing to all? ..sorry but i fail to see that your code is better its just more complex to use when you have to sit and select them first. Or am i missing something here? why would i want to turn it back off again?

  5. Mark says:

    Great work here. I had one question about modifying this. How would I reference the “Use document default” check box that is below the “Allow Smoothing” in the properties? Here’s what I have tried thus far:

    libItems[i].useDocumentDefaultQuality = true;

    It didn’t work, but I wonder if I’m most likely referencing it incorrectly. Any ideas?

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s