Re: [Flashcoders] Help jsfl traceBitmap
For the archive. This is the way to do it. function convert(tFlaPath , tExportPath , tFilename){ debugMessage += \n Vectorizing file : + tFilename + on + (new Date()).toGMTString() + \n; debugMessage += SettingstraceBitmap(100, 2, 'normal' , 'normal') \n; fl.openDocument(tFlaPath); fl.outputPanel.clear(); var doc = fl.getDocumentDOM(); var library = doc.library; var items = library.items.concat(); i = items.length; while (i--) { var item = items[i]; var tLayerN; if (item.itemType == 'movie clip') { var timeline = item.timeline; len = timeline.frameCount; tLayerN = timeline.layers.length; for(var p=0; ptLayerN; p++) { fl.trace(layers index + p); for(var k=0; klen; k++) { library.selectItem(item.name); library.editItem(); timeline.currentFrame = k; timeline.setSelectedFrames(k,k,true); if (doc.selection == [object Bitmap]){ fl.trace('converted: ' + doc.selection); fl.trace('converted: ' + item.name); doc.traceBitmap(100, 2, 'normal' , 'normal'); } } doc.exitEditMode(); } } } filename_new = getNewFileName(tFilename); targetPath = tExportPath + / + filename_new.toUpperCase1() + .swf debugMessage += Exportpath : \n + targetPath; log(tExportPath); doc.exportSWF(targetPath, true); doc.close(false); } Muzak wrote: This one threw me off a bit :) You have to move the timeline playhead for traceBitmap to work. When you enter edit mode, you automatically end up in the first frame, so that's why traceBitmap works for the first frame, and not the others. So, loop through the number of frames, set timeline.currentFrame and then you'll be able to select the elements in that frame and work with them. This should do the trick: var doc = fl.getDocumentDOM(); var library = doc.library; var items = library.items.concat(); var i = items.length; var item; var timeline; var len; var fr; while (i--) { item = items[i]; fl.trace(itemType: + item.itemType); if (item.itemType == movie clip) { library.selectItem(item); library.editItem(); timeline = item.timeline; len = timeline.frameCount; fl.trace(- frameCount: + timeline.frameCount); for(var j=0; jlen; j++) { doc.selectNone(); // move the playhead !! timeline.currentFrame = j; // get reference to current frame object fr = timeline.layers[0].frames[j]; // set doc selection doc.selection = fr.elements; doc.traceBitmap(100, 1, 'pixels', 'normal'); } } } doc.exitEditMode(); regards, Muzak ___ Flashcoders mailing list Flashcoders@chattyfig.figleaf.com http://chattyfig.figleaf.com/mailman/listinfo/flashcoders ___ Flashcoders mailing list Flashcoders@chattyfig.figleaf.com http://chattyfig.figleaf.com/mailman/listinfo/flashcoders
Re: [Flashcoders] Help jsfl traceBitmap
Thnx a million ! J Muzak wrote: This should work, but should probably build in a few more checks in the loop. Like check if there's a bitmap in the currently editted movieclip in the specified frame. What this does is: - loop through the items in the library - check if current item is a movieclip (not a bitmap as you did) - if movieclip, select it and enter edit mode - get the movieclip timeline and set the elements in its first frame/first layer as document selection // here is where you should check if the above selection contains a bitmap - trace bitmap var doc = fl.getDocumentDOM(); var library = doc.library; var items = library.items.concat(); i = items.length; while (i--) { var item = items[i]; fl.trace(itemType: + item.itemType); if (item.itemType == 'movie clip') { library.selectItem(item); library.editItem(); var timeline = item.timeline; fl.trace(- frameCount: + timeline.frameCount); doc.selection = timeline.layers[0].frames[0].elements; doc.traceBitmap(100, 1, 'pixels', 'normal'); } } doc.exitEditMode(); regards, Muzak - Original Message - From: Jiri jiriheitla...@googlemail.com To: Flash Coders List flashcoders@chattyfig.figleaf.com Sent: Monday, February 09, 2009 9:47 AM Subject: [Flashcoders] Help jsfl traceBitmap Hello, i was wondering if someone can help me out with the following. I have a the maintimeline with on it a movieclip. Inside this movieclip is a png, that I would like to trace as a bitmap. I can't seem to target the png that is nested in the movieclip. If i understand correctly I will first need to get it the timeline of the png holder clip from the library and then select the frame. Here is my code which throws a selection: Argument number 1 is invalid. var doc = fl.getDocumentDOM(); var library = doc.library; var items = library.items.concat(); i = items.length; while (i--) { var item = items[i]; if (item.itemType == 'bitmap') { var imageName = item.name.split('.')[0]; var image = doc.getTimeline().layers[0].frames[0].elements[0]; doc.selection = image doc.traceBitmap(100, 100 , 'normal' , 'normal'); } } Hope someone can help! Jiri ___ ___ Flashcoders mailing list Flashcoders@chattyfig.figleaf.com http://chattyfig.figleaf.com/mailman/listinfo/flashcoders ___ Flashcoders mailing list Flashcoders@chattyfig.figleaf.com http://chattyfig.figleaf.com/mailman/listinfo/flashcoders
Re: [Flashcoders] Help jsfl traceBitmap
Muzak and others, everything worked fine, but now i am struggling with movieclips and different frames on their timeline containing 1 png. I followed your described logic. 1. go trhrough lib items. 2. Check if it is a movieclip. 3. For framecount of the timeline, do a loop. 4. For each frame get the elemtens 5. add this to the selection 6. apply the trace bitmap. 7. ERROR! Selcection not set Would someone please be so kind to take a look...it is driving me nuts! Thnx code function convert(tFlaPath , tExportPath){ fl.openDocument(tFlaPath); var doc = fl.getDocumentDOM(); var library = doc.library; var items = library.items; i = items.length; while (i--) { var item = items[i]; if (item.itemType == 'movie clip') { var timeline = item.timeline; var k = timeline.frameCount; library.selectItem(item); library.editItem(); while(k--){ var j = timeline.layers[0].frames[k].elements.length while(j--){ doc.selection = timeline.layers[0].frames[k].elements doc.traceBitmap(100, 1, 'normal', 'normal'); } } doc.exitEditMode(); } } filename_new = getNewFileName(filename); targetPath = tExportPath + / + filename_new.toUpperCase1() + .swf //doc.exportSWF(targetPath, true); //doc.close(false); } /code Muzak wrote: This should work, but should probably build in a few more checks in the loop. Like check if there's a bitmap in the currently editted movieclip in the specified frame. What this does is: - loop through the items in the library - check if current item is a movieclip (not a bitmap as you did) - if movieclip, select it and enter edit mode - get the movieclip timeline and set the elements in its first frame/first layer as document selection // here is where you should check if the above selection contains a bitmap - trace bitmap var doc = fl.getDocumentDOM(); var library = doc.library; var items = library.items.concat(); i = items.length; while (i--) { var item = items[i]; fl.trace(itemType: + item.itemType); if (item.itemType == 'movie clip') { library.selectItem(item); library.editItem(); var timeline = item.timeline; fl.trace(- frameCount: + timeline.frameCount); doc.selection = timeline.layers[0].frames[0].elements; doc.traceBitmap(100, 1, 'pixels', 'normal'); } } doc.exitEditMode(); regards, Muzak - Original Message - From: Jiri jiriheitla...@googlemail.com To: Flash Coders List flashcoders@chattyfig.figleaf.com Sent: Monday, February 09, 2009 9:47 AM Subject: [Flashcoders] Help jsfl traceBitmap Hello, i was wondering if someone can help me out with the following. I have a the maintimeline with on it a movieclip. Inside this movieclip is a png, that I would like to trace as a bitmap. I can't seem to target the png that is nested in the movieclip. If i understand correctly I will first need to get it the timeline of the png holder clip from the library and then select the frame. Here is my code which throws a selection: Argument number 1 is invalid. var doc = fl.getDocumentDOM(); var library = doc.library; var items = library.items.concat(); i = items.length; while (i--) { var item = items[i]; if (item.itemType == 'bitmap') { var imageName = item.name.split('.')[0]; var image = doc.getTimeline().layers[0].frames[0].elements[0]; doc.selection = image doc.traceBitmap(100, 100 , 'normal' , 'normal'); } } Hope someone can help! Jiri ___ ___ Flashcoders mailing list Flashcoders@chattyfig.figleaf.com http://chattyfig.figleaf.com/mailman/listinfo/flashcoders ___ Flashcoders mailing list Flashcoders@chattyfig.figleaf.com http://chattyfig.figleaf.com/mailman/listinfo/flashcoders
Re: [Flashcoders] Help jsfl traceBitmap
This one threw me off a bit :) You have to move the timeline playhead for traceBitmap to work. When you enter edit mode, you automatically end up in the first frame, so that's why traceBitmap works for the first frame, and not the others. So, loop through the number of frames, set timeline.currentFrame and then you'll be able to select the elements in that frame and work with them. This should do the trick: var doc = fl.getDocumentDOM(); var library = doc.library; var items = library.items.concat(); var i = items.length; var item; var timeline; var len; var fr; while (i--) { item = items[i]; fl.trace(itemType: + item.itemType); if (item.itemType == movie clip) { library.selectItem(item); library.editItem(); timeline = item.timeline; len = timeline.frameCount; fl.trace(- frameCount: + timeline.frameCount); for(var j=0; jlen; j++) { doc.selectNone(); // move the playhead !! timeline.currentFrame = j; // get reference to current frame object fr = timeline.layers[0].frames[j]; // set doc selection doc.selection = fr.elements; doc.traceBitmap(100, 1, 'pixels', 'normal'); } } } doc.exitEditMode(); regards, Muzak ___ Flashcoders mailing list Flashcoders@chattyfig.figleaf.com http://chattyfig.figleaf.com/mailman/listinfo/flashcoders
Re: [Flashcoders] Help jsfl traceBitmap
This one threw me off a bit :) Tell me about it, it did my head in all day.. When you enter edit mode, you automatically end up in the first frame, That explains why, although looping through the frames, it was always only the first one to be converted before the error was thrown. I will give your suggestion a try tomorrow and cross my fingers it works. Thank you again. jiri Muzak wrote: This one threw me off a bit :) You have to move the timeline playhead for traceBitmap to work. When you enter edit mode, you automatically end up in the first frame, so that's why traceBitmap works for the first frame, and not the others. So, loop through the number of frames, set timeline.currentFrame and then you'll be able to select the elements in that frame and work with them. This should do the trick: var doc = fl.getDocumentDOM(); var library = doc.library; var items = library.items.concat(); var i = items.length; var item; var timeline; var len; var fr; while (i--) { item = items[i]; fl.trace(itemType: + item.itemType); if (item.itemType == movie clip) { library.selectItem(item); library.editItem(); timeline = item.timeline; len = timeline.frameCount; fl.trace(- frameCount: + timeline.frameCount); for(var j=0; jlen; j++) { doc.selectNone(); // move the playhead !! timeline.currentFrame = j; // get reference to current frame object fr = timeline.layers[0].frames[j]; // set doc selection doc.selection = fr.elements; doc.traceBitmap(100, 1, 'pixels', 'normal'); } } } doc.exitEditMode(); regards, Muzak ___ Flashcoders mailing list Flashcoders@chattyfig.figleaf.com http://chattyfig.figleaf.com/mailman/listinfo/flashcoders ___ Flashcoders mailing list Flashcoders@chattyfig.figleaf.com http://chattyfig.figleaf.com/mailman/listinfo/flashcoders
[Flashcoders] Help jsfl traceBitmap
Hello, i was wondering if someone can help me out with the following. I have a the maintimeline with on it a movieclip. Inside this movieclip is a png, that I would like to trace as a bitmap. I can't seem to target the png that is nested in the movieclip. If i understand correctly I will first need to get it the timeline of the png holder clip from the library and then select the frame. Here is my code which throws a selection: Argument number 1 is invalid. var doc = fl.getDocumentDOM(); var library = doc.library; var items = library.items.concat(); i = items.length; while (i--) { var item = items[i]; if (item.itemType == 'bitmap') { var imageName = item.name.split('.')[0]; var image = doc.getTimeline().layers[0].frames[0].elements[0]; doc.selection = image doc.traceBitmap(100, 100 , 'normal' , 'normal'); } } Hope someone can help! Jiri ___ Flashcoders mailing list Flashcoders@chattyfig.figleaf.com http://chattyfig.figleaf.com/mailman/listinfo/flashcoders
Re: [Flashcoders] Help jsfl traceBitmap
This should work, but should probably build in a few more checks in the loop. Like check if there's a bitmap in the currently editted movieclip in the specified frame. What this does is: - loop through the items in the library - check if current item is a movieclip (not a bitmap as you did) - if movieclip, select it and enter edit mode - get the movieclip timeline and set the elements in its first frame/first layer as document selection // here is where you should check if the above selection contains a bitmap - trace bitmap var doc = fl.getDocumentDOM(); var library = doc.library; var items = library.items.concat(); i = items.length; while (i--) { var item = items[i]; fl.trace(itemType: + item.itemType); if (item.itemType == 'movie clip') { library.selectItem(item); library.editItem(); var timeline = item.timeline; fl.trace(- frameCount: + timeline.frameCount); doc.selection = timeline.layers[0].frames[0].elements; doc.traceBitmap(100, 1, 'pixels', 'normal'); } } doc.exitEditMode(); regards, Muzak - Original Message - From: Jiri jiriheitla...@googlemail.com To: Flash Coders List flashcoders@chattyfig.figleaf.com Sent: Monday, February 09, 2009 9:47 AM Subject: [Flashcoders] Help jsfl traceBitmap Hello, i was wondering if someone can help me out with the following. I have a the maintimeline with on it a movieclip. Inside this movieclip is a png, that I would like to trace as a bitmap. I can't seem to target the png that is nested in the movieclip. If i understand correctly I will first need to get it the timeline of the png holder clip from the library and then select the frame. Here is my code which throws a selection: Argument number 1 is invalid. var doc = fl.getDocumentDOM(); var library = doc.library; var items = library.items.concat(); i = items.length; while (i--) { var item = items[i]; if (item.itemType == 'bitmap') { var imageName = item.name.split('.')[0]; var image = doc.getTimeline().layers[0].frames[0].elements[0]; doc.selection = image doc.traceBitmap(100, 100 , 'normal' , 'normal'); } } Hope someone can help! Jiri ___ ___ Flashcoders mailing list Flashcoders@chattyfig.figleaf.com http://chattyfig.figleaf.com/mailman/listinfo/flashcoders