PDA

View Full Version : Problem:jsfl to publish all movieclips as jpegs


Narendrakumar
05-30-2006, 04:17 AM
can anybody provide solution to publish all moviclips as separate jpegs thru
jsfl.:confused:

jjbilly
05-30-2006, 02:03 PM
I've not done this, but what you'll need to do is save a publish setting which specifies that only jpgs should be published. publish settings are saved as XML files... you then need to iterate across the project, opening your files, loading this publish setting, and publishing.

Narendrakumar
05-31-2006, 08:29 AM
thanks for ur(jjbilly) reply.

my actual objective is to publish each and every movieclip in a library as separate jpegs.

for example: suppose a library holds three diffrent movieclips(camel,lion,rat)]

what i need is to publish camel movieclip as camel.jpg, lion as lion.jpg

in such a manner.:(

jjbilly
05-31-2006, 02:08 PM
If there's a way of doing that directly, I don't know it. Instead, perhaps this laborious routine would work:

Go through the library, and copy each image into a new document, then publish that new document (with publish as jpeg publish settings)...

krayzeebean
05-31-2006, 07:00 PM
How about a loop that clears the stage, adds a movie clip to the stage, and then publishes a jpeg?

Narendrakumar
06-01-2006, 04:03 AM
Thanks jjbilly and krayzeebean

i hope that ur's solution would do....;)

johnnystorm
06-07-2006, 08:18 PM
I wrote this to export all Bitmaps inside of a FLA file to PNGs, I'm sure you could tweak it to do JPEGs but I wouldn't recommend it.

// JS Export All Bitmaps
//
// Copyright (c) 2005 JohnnyStorm.com. All rights reserved.
//
// http://www.johnnystorm.com
//
// version .01 (22 September 2005)
//
fl.outputPanel.clear()
var doc = fl.getDocumentDOM();
var tl = doc.getTimeline();
var lib = doc.library;
var newSel = new Array();
var l = 0;

var filenames = new Array();
for(var $i = 0; $i < lib.items.length; $i++) {
if(lib.items[$i].itemType == "bitmap") {
filenames.push(lib.items[$i].name);
}
}
var folderURI = decodeURI(fl.browseForFolderURL("Select a folder.").split("file:///").join(""));
var temp = folderURI.split("/");
var destFolder = "/";
for(var i = 1; i < temp.length; i++) {
destFolder += temp[i] + "/";
}
//fl.trace(folderURI);
if(folderURI) {
for(var n = 0; n < filenames.length; n++) {
lib.selectItem(filenames[n], true);
var selItems = lib.getSelectedItems();
lib.addItemToDocument({x:0, y:0});
l = 1;
exportImage(filenames[n]);
}
}
function exportImage(file) {
if(doc.selection[0] || doc.selection.length > 1) {
var newSel = doc.selection;
var type = newSel[0].elementType;
if(type == "instance") {
var sel = newSel[0];
var w = sel.width;
var h = sel.height;
if(file.indexOf(".") != -1) {
var temp = file.split(".");
var file = temp[0];
}
createProfile(file, w, h, destFolder);
if(l == 1) {
doc.clipCut();
} else {
doc.clipCopy();
}
fl.createDocument();
doc = fl.getDocumentDOM();
fl.getDocumentDOM().importPublishProfile(fl.config URI + "Publish%20Profiles/png.xml");
doc.currentPublishProfile = "png";
doc.clipPaste();
doc.selectAll();
var sel = doc.selection[0];
doc.width = Math.floor(w);
doc.height = Math.floor(h);
doc.moveSelectionBy({x:-sel.left, y:-sel.top});
doc.selectNone();
fl.getDocumentDOM().publish();
fl.getDocumentDOM().close(false);

}
}
}
function createProfile(name, w, h, path) {
profile = '<?xml version="1.0"?>\n'+
'<flash_profile version="1.0" name="Default">\n'+
' <PublishFormatProperties enabled="true">\n'+
' <defaultNames>0</defaultNames>\n'+
' <flash>0</flash>\n'+
' <generator>0</generator>\n'+
' <projectorWin>0</projectorWin>\n'+
' <projectorMac>0</projectorMac>\n'+
' <html>0</html>\n'+
' <gif>0</gif>\n'+
' <jpeg>0</jpeg>\n'+
' <png>1</png>\n'+
' <qt>0</qt>\n'+
' <rnwk>0</rnwk>\n'+
' <flashDefaultName>0</flashDefaultName>\n'+
' <generatorDefaultName>1</generatorDefaultName>\n'+
' <projectorWinDefaultName>1</projectorWinDefaultName>\n'+
' <projectorMacDefaultName>1</projectorMacDefaultName>\n'+
' <htmlDefaultName>1</htmlDefaultName>\n'+
' <gifDefaultName>1</gifDefaultName>\n'+
' <jpegDefaultName>0</jpegDefaultName>\n'+
' <pngDefaultName>0</pngDefaultName>\n'+
' <qtDefaultName>1</qtDefaultName>\n'+
' <rnwkDefaultName>1</rnwkDefaultName>\n'+
' <flashFileName>' + path + name + '.swf</flashFileName>\n'+
' <generatorFileName>' + path + name + '.swt</generatorFileName>\n'+
' <projectorWinFileName>' + path + name + '.exe</projectorWinFileName>\n'+
' <projectorMacFileName>' + path + name + '.hqx</projectorMacFileName>\n'+
' <htmlFileName>' + path + name + '</htmlFileName>\n'+
' <gifFileName>' + path + name + '.gif</gifFileName>\n'+
' <jpegFileName>' + path + name + '.jpg</jpegFileName>\n'+
' <pngFileName>' + path + name + '.png</pngFileName>\n'+
' <qtFileName>' + path + name + '.mov</qtFileName>\n'+
' <rnwkFileName>' + path + name + '.smil</rnwkFileName>\n'+
' </PublishFormatProperties>\n'+
' <PublishHtmlProperties enabled="true">\n'+
' <Width>' + w + '</Width>\n'+
' <Height>' + h + '</Height>\n'+
' <Align>0</Align>\n'+
' <Units>0</Units>\n'+
' <Loop>1</Loop>\n'+
' <StartPaused>0</StartPaused>\n'+
' <Scale>0</Scale>\n'+
' <HorizontalAlignment>1</HorizontalAlignment>\n'+
' <VerticalAlignment>1</VerticalAlignment>\n'+
' <Quality>4</Quality>\n'+
' <WindowMode>0</WindowMode>\n'+
' <DisplayMenu>1</DisplayMenu>\n'+
' <DeviceFont>0</DeviceFont>\n'+
' <TemplateFileName>Default.html</TemplateFileName>\n'+
' <showTagWarnMsg>1</showTagWarnMsg>\n'+
' </PublishHtmlProperties>\n'+
' <PublishFlashProperties enabled="true">\n'+
' <TopDown>0</TopDown>\n'+
' <Report>0</Report>\n'+
' <Protect>0</Protect>\n'+
' <OmitTraceActions>0</OmitTraceActions>\n'+
' <Quality>100</Quality>\n'+
' <StreamFormat>0</StreamFormat>\n'+
' <StreamCompress>7</StreamCompress>\n'+
' <EventFormat>0</EventFormat>\n'+
' <EventCompress>7</EventCompress>\n'+
' <OverrideSounds>0</OverrideSounds>\n'+
' <Version>6</Version>\n'+
' <ExternalPlayer></ExternalPlayer>\n'+
' <ActionScriptVersion>1</ActionScriptVersion>\n'+
' <PackageExportFrame>1</PackageExportFrame>\n'+
' <PackagePaths></PackagePaths>\n'+
' <DebuggingPermitted>0</DebuggingPermitted>\n'+
' <DebuggingPassword></DebuggingPassword>\n'+
' <CompressMovie>1</CompressMovie>\n'+
' <FireFox>0</FireFox>\n'+
' <DeviceSound>0</DeviceSound>\n'+
' </PublishFlashProperties>\n'+
' <PublishJpegProperties enabled="true">\n'+
' <Width>' + w + '</Width>\n'+
' <Height>' + h + '</Height>\n'+
' <Progressive>0</Progressive>\n'+
' <DPI>4718592</DPI>\n'+
' <Size>0</Size>\n'+
' <Quality>80</Quality>\n'+
' <MatchMovieDim>1</MatchMovieDim>\n'+
' </PublishJpegProperties>\n'+
' <PublishRNWKProperties enabled="true">\n'+
' <exportFlash>1</exportFlash>\n'+
' <flashBitRate>12</flashBitRate>\n'+
' <exportAudio>1</exportAudio>\n'+
' <audioFormat>0</audioFormat>\n'+
' <singleRateAudio>0</singleRateAudio>\n'+
' <realVideoRate>100000</realVideoRate>\n'+
' <speed28K>1</speed28K>\n'+
' <speed56K>1</speed56K>\n'+
' <speedSingleISDN>0</speedSingleISDN>\n'+
' <speedDualISDN>0</speedDualISDN>\n'+
' <speedCorporateLAN>0</speedCorporateLAN>\n'+
' <speed256K>0</speed256K>\n'+
' <speed384K>0</speed384K>\n'+
' <speed512K>0</speed512K>\n'+
' <exportSMIL>1</exportSMIL>\n'+
' </PublishRNWKProperties>\n'+
' <PublishGifProperties enabled="true">\n'+
' <Width>' + w + '</Width>\n'+
' <Height>' + h + '</Height>\n'+
' <Animated>0</Animated>\n'+
' <MatchMovieDim>1</MatchMovieDim>\n'+
' <Loop>1</Loop>\n'+
' <LoopCount></LoopCount>\n'+
' <OptimizeColors>1</OptimizeColors>\n'+
' <Interlace>0</Interlace>\n'+
' <Smooth>1</Smooth>\n'+
' <DitherSolids>0</DitherSolids>\n'+
' <RemoveGradients>0</RemoveGradients>\n'+
' <TransparentOption></TransparentOption>\n'+
' <TransparentAlpha>128</TransparentAlpha>\n'+
' <DitherOption></DitherOption>\n'+
' <PaletteOption></PaletteOption>\n'+
' <MaxColors>255</MaxColors>\n'+
' <PaletteName></PaletteName>\n'+
' </PublishGifProperties>\n'+
' <PublishPNGProperties enabled="true">\n'+
' <Width>' + w + '</Width>\n'+
' <Height>' + h + '</Height>\n'+
' <OptimizeColors>1</OptimizeColors>\n'+
' <Interlace>0</Interlace>\n'+
' <Transparent>0</Transparent>\n'+
' <Smooth>1</Smooth>\n'+
' <DitherSolids>0</DitherSolids>\n'+
' <RemoveGradients>0</RemoveGradients>\n'+
' <MatchMovieDim>1</MatchMovieDim>\n'+
' <DitherOption>None</DitherOption>\n'+
' <FilterOption>None</FilterOption>\n'+
' <PaletteOption>Web 216</PaletteOption>\n'+
' <BitDepth>24-bit with Alpha</BitDepth>\n'+
' <MaxColors>255</MaxColors>\n'+
' <PaletteName></PaletteName>\n'+
' </PublishPNGProperties>\n'+
' <PublishQTProperties enabled="true">\n'+
' <Width>' + w + '</Width>\n'+
' <Height>' + h + '</Height>\n'+
' <MatchMovieDim>1</MatchMovieDim>\n'+
' <UseQTSoundCompression>0</UseQTSoundCompression>\n'+
' <AlphaOption></AlphaOption>\n'+
' <LayerOption></LayerOption>\n'+
' <QTSndSettings>00000000</QTSndSettings>\n'+
' <ControllerOption>0</ControllerOption>\n'+
' <Looping>0</Looping>\n'+
' <PausedAtStart>0</PausedAtStart>\n'+
' <PlayEveryFrame>0</PlayEveryFrame>\n'+
' <Flatten>1</Flatten>\n'+
' </PublishQTProperties>\n'+
'</flash_profile>';
fl.outputPanel.clear()
fl.trace(profile);
fl.outputPanel.save(fl.configURI + "Publish%20Profiles/png.xml");
fl.outputPanel.clear()
}

Narendrakumar
06-11-2006, 03:57 PM
Thanks to Johnnystorm

ur solution works perfectly.;)