RE: [Flashcoders] Flash extension question

2007-03-21 Thread Steven Sacks | BLITZ
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.

___
Flashcoders@chattyfig.figleaf.com
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


Re: [Flashcoders] Flash extension question

2007-03-21 Thread Jobe Makar

Thanks Steven,

doc.path was the breakthrough that I needed. For some reason I didn't notice 
that in the documentaiton. Your code is useful as well. Thanks for the help!


Jobe Makar
http://www.electrotank.com
http://www.electro-server.com
phone: 252-627-8026
mobile: 919-609-0408
fax: 919-341-8104
- Original Message - 
From: Steven Sacks | BLITZ [EMAIL PROTECTED]

To: flashcoders@chattyfig.figleaf.com
Sent: Wednesday, March 21, 2007 4:31 PM
Subject: RE: [Flashcoders] Flash extension question


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.

___
Flashcoders@chattyfig.figleaf.com
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


___
Flashcoders@chattyfig.figleaf.com
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