Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
Discussion GroupsGeneralPHPASPPerlColdFusionFlashHTML, CSS, ScriptsBrowsers

Webmaster Forum / Flash / General Flash Topics / July 2008



Tip: Looking for answers? Try searching our database.

Creating multiple movie clips from bitmaps

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
LindnArden - 07 Jul 2008 13:32 GMT
Hi all....I need to convert 25 bitmaps to individual movie clips preferably in
an automated way rather than dragging them onto the stage and right clicking on
each one.

I googled a solution and found someone who said 'run the script below'.....as
something of a novice, what I don't know is the process for running this
script...can anyone assist ??

if (fl.getDocumentDOM() == null) {
fl.trace("Error: No document open.");
} else {
if (fl.getDocumentDOM().selection.length == 0) {
fl.trace("Error: Nothing selected.");
} else {

var convertedBitmaps = new Array();

var selArr = fl.getDocumentDOM().selection;
for (var i = 0; i < selArr.length; i++) {

var instanceRef = selArr[i]
if (instanceRef.instanceType == "bitmap") {

var libraryItemRef = instanceRef.libraryItem;
var newName = stripExtension(libraryItemRef.name);

fl.getDocumentDOM().selectNone();
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.");
}
}

}

fl.getDocumentDOM().selectNone();
}
}

function stripExtension(str) {
var pos = str.lastIndexOf(".");
if (pos == -1) {
return str;
} else {
return str.slice(0,pos);
}
}
DMennenoh **AdobeCommunityExpert** - 07 Jul 2008 15:51 GMT
You would save the script as a .jsfl file, and then you can run it from the
Commands > Run Command menu.

Signature

Dave -
www.offroadfire.com
Head Developer
http://www.blurredistinction.com
Adobe Community Expert
http://www.adobe.com/communities/experts/

LindnArden - 07 Jul 2008 16:25 GMT
Thanks for that....I copied and pasted the script into notepad and saved it  as
a .jsfl file, then went Comands -> Run Command and selected it but nothing
seemed to happen.

Am I barking up the wrong tree ?
DMennenoh **AdobeCommunityExpert** - 07 Jul 2008 17:45 GMT
Something happened - look in the Output panel. First, you need to remove
that line break on line 21 - after top, so it's "topleft"

Then it should work.

Signature

Dave -
www.offroadfire.com
Head Developer
http://www.blurredistinction.com
Adobe Community Expert
http://www.adobe.com/communities/experts/

LindnArden - 07 Jul 2008 18:27 GMT
Aha ! Something did happen.....I got the following message for each bitmap

Error: Couldn't convert Yellow_03 to symbol.
Error: Couldn't convert Yellow_02 to symbol.
Error: Couldn't convert Yellow_01 to symbol.
Error: Couldn't convert White_03 to symbol. etc etc
DMennenoh **AdobeCommunityExpert** - 07 Jul 2008 20:12 GMT
OK - I tested this a bit further - make sure it's 'top left' and not
'topleft'. Once I did that, and selected the bitmaps on stage, it created
clips from all with no problem.

If you still have issues let me know.

Signature

Dave -
www.offroadfire.com
Head Developer
http://www.blurredistinction.com
Adobe Community Expert
http://www.adobe.com/communities/experts/

LindnArden - 07 Jul 2008 20:55 GMT
Still no joy sadly - (I have it as 'top left') - I get a message, for each
bitmap file, saying 'The name Yellow_03 is taken'  or whatever name the bitmap
has, which then results in the same error message in the Output box.....
DMennenoh **AdobeCommunityExpert** - 08 Jul 2008 03:50 GMT
Hmmm. I could get it to produce that error when there was already another
clip by the name it wanted to make. The script removes the .jpg portion, so
if you have xx.jpg on stage, it'll make a movieClip named xx in the library.
If there's already a clip named xx you'll get that error.

Signature

Dave -
www.offroadfire.com
Head Developer
http://www.blurredistinction.com
Adobe Community Expert
http://www.adobe.com/communities/experts/

LindnArden - 08 Jul 2008 06:20 GMT
The odd thing is that there is nothing else in the library except the bitmaps....
LindnArden - 08 Jul 2008 07:57 GMT
I couldn't get it to work but I found another script on the net (below) which
does seem to work. The next step is to try and understand what the hell the
script means......
:confused;
thanks a lot for your help Dave - I'm sure I'll be back.

var dom = fl.getDocumentDOM();
var lib = dom.library;
var newSel = [];

var selItems = lib.getSelectedItems();

for( var i=0; i<selItems.length; i++ )
{

var s = selItems[i].name.split( "." );

var nameId = s[ 0 ] + "_mc";
lib.addNewItem( "movie clip", nameId );
lib.editItem( nameId );

var tl = dom.getTimeline();
tl.layers[0].name = "L1";
lib.addItemToDocument( {x:0, y:0}, selItems[i].name );

newSel[0] = tl.layers[ 0 ].frames[ 0 ].elements[ 0 ];

dom.selectNone();
dom.selection = newSel;
var mat = dom.selection[0].matrix;
mat.tx = 0;
mat.ty = 0;
dom.selection[0].matrix = mat;
dom.selectNone();
dom.exitEditMode();

}
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2009 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.