If you want to export to a different directory, you'll have to modify
the publish settings xml file, which I discuss on my blog...which for
some reason is down right now (writes email to hosting company)...so
I'll copy and paste the code here. If you are publishing to the same
folder as the FLA, you only need to doc.publish() and the first two
functions.
var doc = fl.getDocumentDOM();
function getRelativePath() {
var pathArr = doc.path.split("\\");
pathArr.length--;
return("file:///" + pathArr.join("/") + "/");
}
function saveFile(s) {
var fPath = getRelativePath() + s + ".fla";
fl.saveDocument(doc, fPath);
}
function cleanup() {
var fPath = getRelativePath() + "PublishProfile.xml";
FLfile.remove(fPath);
}
function publishTheSWF(s) {
setPublishSettings(s);
saveFile(s);
cleanup();
doc.publish();
}
function setPublishSettings(s) {
var xml, from, to, snip;
var fPath = getRelativePath() + "PublishProfile.xml";
// export the profile and read it in
doc.exportPublishProfile(fPath);
xml = FLfile.read(fPath);
var folderPath = "../deploy/";
// replace the publish paths
from = xml.indexOf("<flashFileName>");
to = xml.indexOf("</flashFileName>");
snip = xml.substring(from, to);
xml = xml.split(snip).join("<flashFileName>" + folderPath + s);
// set player version
v = 8;
from = xml.indexOf("<Version>");
to = xml.indexOf("</Version>");
snip = xml.substring(from, to);
xml = xml.split(snip).join("<Version>" + v);
var nodes = {};
nodes.generatorFileName = "swt";
nodes.projectorWinFileName = "exe";
nodes.projectorMacFileName = "hqx";
nodes.htmlFileName = "html";
nodes.gifFileName = "gif";
nodes.jpegFileName = "jpg";
nodes.pngFileName = "png";
nodes.qtFileName = "mov";
nodes.rnwkFileName = "smil";
for (var n in nodes) {
from = xml.indexOf("<" + n + ">");
to = xml.indexOf("</" + n + ">");
snip = xml.substring(from, to);
xml = xml.split(snip).join("<" + n + ">" + s + "." +
nodes[n]);
}
// write the file
FLfile.write(fPath, xml);
// import the altered profile
doc.importPublishProfile(fPath);
}
You can then use:
publishTheSWF("swfName");
Note: do not include the extension.
_______________________________________________
[email protected]
To change your subscription options or search the archive:
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders
Brought to you by Fig Leaf Software
Premier Authorized Adobe Consulting and Training
http://www.figleaf.com
http://training.figleaf.com