Home Tutorials Forums Articles Blogs Movies Library Employment Press

Go Back   ActionScript.org Forums > Extensions and Plugins > JSFL - Extending Flash

Thread Tools Rate Thread Display Modes
Old 04-21-2007, 04:30 PM   #1
Registered User
Join Date: Apr 2007
Posts: 1
Default help with automating import process of bitmaps and converting them to movieclips

Hi, I would like to import lots of bitmaps from a folder to the library and then I also want to create movieclips of each of them and giving them the same name of the file plus adding the word "mc_" to the beginning of the moveiclip name. Also the linkage ID name would be equal to the file name plus "mcID_" at the beginning of the moveiclip name.
Setting up each of them to be a movieclip would take a long time if I individually have to deal with lots of images.

So for example: "background.jpg" would be imported and would be converted to a movieclip symbol with the name "mc_background" and the linkage ID name of that movieclip would be set to "mcID_background".
I do not need to place them on the timeline but I want them to be available in the Library panel.

I am a designer not programmer and I have not used JSFL at all so I would need some down to earth assistance on how to achieve the above mentioned automation.
Thank you in advance,
jimdasaint is offline   Reply With Quote
Old 05-03-2007, 09:49 PM   #2
Registered User
bigevilbrain's Avatar
Join Date: Mar 2006
Posts: 36

This is pretty close to what you need. It will convert all selected bitmaps to movieclips. The only difference is that you have to manually import the images to the stage. Then select them and run this script.

Also, it will add "bit" before the name and also strip the file extension. For instance: "background.jpg" becomes "bit - background" and the linkage is "bit_background". (You can change it to "mc" and "mcID" if you wish.)

So, copy this code and save it in a ".jsfl" file in the "Commands" folder. Enjoy!

// ----------------
// ----------------
// VERSION: 1.1
// DATE:    9/18/06
// HOTKEY:  

if (fl.getDocumentDOM() == null) {
	fl.trace("Error: No document open.");
} else {
	if (fl.getDocumentDOM().selection.length == 0) { 
		fl.trace("Error: Nothing selected.");
	} else {
		var selArr = fl.getDocumentDOM().selection;
		for (var i = 0; i < selArr.length; i++) {
			var instanceRef = selArr[i]
			if (instanceRef.instanceType == "bitmap") {
				// Only convert selected bitmaps.
				var libraryItemRef = instanceRef.libraryItem;
				var newName = "bit - " + stripExtension(libraryItemRef.name);
				fl.getDocumentDOM().selection = new Array(instanceRef);
				var mc = fl.getDocumentDOM().convertToSymbol("movie clip", newName, "top left");
				if (mc == null) {
					// Throws an error, on screen anyway...
					fl.trace("Error: Couldn't convert "+newName+" to symbol.");
				// Set linkage data
				mc.linkageExportForAS = true;
				mc.linkageExportInFirstFrame = true;
				mc.linkageIdentifier = "bit_" + stripExtension(libraryItemRef.name);


function stripExtension(str) {
	var pos = str.lastIndexOf(".");
	if (pos == -1) {
		return str;
	} else {
		return str.slice(0,pos);
bigevilbrain is offline   Reply With Quote
Old 05-11-2007, 07:01 PM   #3
GraphNick Design
myFUD's Avatar
Join Date: Jan 2006
Location: Utah
Posts: 107

This works great for Flash 8. But in Flash 9 there is a problem. I Have imported bitmaps from a layered psd so that the reference "libraryItemRef.name" is different than if the bitmap was brought in individually. It uses the original name of the psd and not the layer name (the name of the bitmap it creates).

Does anyone know what the reference for "libraryItemRef.name" would be in this case? A logic statement would be needed to be able to tell the difference between the way the bitmaps were imported.
--GraphNick Design--

myFUD is offline   Reply With Quote

Thread Tools
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Converting Text objects to Bitmaps Chuck Taylor ActionScript 3.0 8 03-13-2007 05:22 PM

All times are GMT. The time now is 01:31 AM.

Follow actionscriptorg on Twitter


Powered by vBulletin® Version 3.8.5
Copyright ©2000 - 2014, Jelsoft Enterprises Ltd.
Ad Management plugin by RedTyger
Copyright 2000-2013 ActionScript.org. All Rights Reserved.
Your use of this site is subject to our Privacy Policy and Terms of Use.