Flash CS3 extension to compress bitmap faster

Have you ever had to import a sequence of images in Flash and then had to change the compression by hand for each of the images imported? It’s really boring to do and also time consuming. I mean for each image, you have to select it in the library, right click, go in properties, choose the compression and than click apply. I couldn’t believe that there wasn’t any better way to do this. This week I saw a video by Lee Brimelow on how to create custom panel in the Flash IDE and decided to take the matter in my own hands.

So at the bottom of this post is the link to download my extension. It’s not perfect, I think I could still had some options, but it does pretty much what I wanted.  Basically, it lets you select multiple bitmaps in your library and change the compression setting once for all of them. The zip file also contains the source code of the package if you want to play with it. If you just want to see how it is done, I will simply paste the code here. There is 2 kind of language in there: ActionScript 3 and JSFL. The JSFL is the string that the MMExecute function takes. Here is all of it:

[as]

compress.addEventListener(MouseEvent.CLICK, manageClick);
function manageClick(e:MouseEvent):void{
if (numCompress.text != “”){
var myNum:int = int(numCompress.text);
if (myNum < 0){
myNum = 0;
}
if (myNum > 100){
myNum = 100;
}
var jsfl:String = “var selItems = fl.getDocumentDOM().library.getSelectedItems();for (var i = 0; i < selItems.length; i++){if (selItems[i].itemType == 'bitmap'){selItems[i].allowSmoothing = " + mySmooth.selected + ";selItems[i].compressionType = 'photo';selItems[i].useImportedJPEGQuality = false;selItems[i].quality = " + myNum + ";}}"
MMExecute(jsfl);
}
}

[/as]

Here is the JSFL formatted in an understandable kinda way:

[as]

var selItems = fl.getDocumentDOM().library.getSelectedItems();
for (var i = 0; i < selItems.length; i++){
if (selItems[i].itemType == 'bitmap'){
selItems[i].allowSmoothing = " + mySmooth.selected + ";
selItems[i].compressionType = 'photo';
selItems[i].useImportedJPEGQuality = false;
selItems[i].quality = " + myNum + ";
}
}

[/as]

It was pretty simple to do, but it seems strange how you use the JSFL since you have to put it all on one line in order to call the MMExecute function. Well here it is, have fun with it.

Compress Images custom panel

, , , ,

  1. #1 by Breanauw - March 25th, 2008 at 15:29

    thanks much, man

  2. #2 by Michael Tidwell - April 16th, 2008 at 08:07

    Thank you for this! I had a small video of a flame that had been exported as PNG images… I was 1/3 of the way of setting the compression on each of the 90 images (URGGH) when I found your extension – it’s beyond me why Flash doesn’t have this built in.

    Thanks!

  3. #3 by chris - August 6th, 2008 at 14:17

    THANK YOU!!!

    yes – how is this not already part of flash?! It’s absurd that such a standard app has so many design oversights.

  4. #4 by Jorge - August 14th, 2008 at 17:40

    Thank you!

  5. #5 by JiZ - September 23rd, 2008 at 05:55

    Thanks a lot!
    You saved me a LOT of work.

  6. #6 by Josh - July 22nd, 2009 at 16:27

    You just saved me an unreal amount of time. I’ve been trying to figure out a way to do this for a while.

    Thanks for the lifesaver!

    - Josh

  7. #7 by sandeep panwar - November 12th, 2010 at 20:22

    hi
    i m webdevloper . i workfreelancer . i need a code in as3
    as convert swf file with action script . can so do possibale
    if possibale pls send to soluation of problam on my mail id . i create a animation with as3 that to export in swf file . accourding to mine as work possibal from flash java script(jsfl) . i do’t know jsfl to impliment in as3 . pls give me any soluation . that work is need in my project.

    regards sandeep panwar

(will not be published)
Subscribe to comments feed
  1. No trackbacks yet.