Posts Tagged Compress Bitmap

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

, , , ,

7 Comments



Parse error: syntax error, unexpected ';' in /homepages/25/d169645162/htdocs/wp-content/themes/fusion/footer.php on line 13