-
-
Save alebianco/b6a55a3fb2c572bfdcc2c3067c896927 to your computer and use it in GitHub Desktop.
JSFL file to publish multiple Flash files with single JSFL command
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var tempDoc=undefined; | |
var searchSubDir="true" | |
if(fl.documents.length==0){ | |
tempDoc=fl.createDocument(); | |
} | |
var folder = getFolderURIFromUser(); | |
exportlist=new Array(); | |
if(folder){ | |
if(folder.substr(0,8)!="file:///"){ | |
folder="file:///"+folder.split(":").join("|").split("\\").join("/"); | |
} | |
if(folder.substr(folder.length-1,1)!="/"){ | |
folder=folder+"/"; | |
} | |
checkFolder(folder,exportlist,searchSubDir); | |
} | |
var totaltime=0; | |
if(exportlist.length==0){ | |
alert("No file need to publish."); | |
}else{ | |
if(confirm(exportlist.length+" files will be updated and published")){ | |
for(var i=0;i<exportlist.length;i++){ | |
setPublishProfileSettings(exportlist[i]); | |
//FLfile.write("file:///c:/exportlog.txt", exportlog);//uncomment if you want to log all files | |
} | |
} | |
} | |
function checkFolder(folder,list,checkSub,pre){ | |
if(pre==undefined){ | |
pre=""; | |
} | |
var flas=FLfile.listFolder(folder+"*.fla","files"); | |
for(var i=0;i<flas.length;i++){ | |
list.push(folder+flas[i]); | |
} | |
if(checkSub=="true"){ | |
var flds=FLfile.listFolder(folder,"directories"); | |
for(var i=0;i<flds.length;i++){ | |
checkFolder(folder+flds[i]+"/",list,checkSub,pre+" "); | |
} | |
} | |
} | |
function setPublishProfileSettings(fileURI) | |
{ | |
if (fl.fileExists(fileURI)){ | |
var xml, from, to, delta; | |
var doc=fl.openDocument(fileURI); | |
var fileName = fileURI.split("/").pop(); | |
var folderPath = fileURI.split(fileName)[0]; | |
fileName = fileName.split(".")[0]; | |
var pPath = folderPath + "/_Profile_.xml"; | |
fl.getDocumentDOM().exportPublishProfile(pPath); | |
xml = FLfile.read(pPath); | |
var swfpath=fileName+".swf"; | |
from = xml.indexOf("<flashFileName>"); | |
to = xml.indexOf("</flashFileName>"); | |
delta = xml.substring(from, to); | |
xml = xml.split(delta).join("<flashFileName>"+swfpath); | |
from = xml.indexOf("<Version>"); | |
to = xml.indexOf("</Version>"); | |
delta = xml.substring(from, to); | |
xml = xml.split(delta).join("<Version>10"); | |
from = xml.indexOf("<ActionScriptVersion>"); | |
to = xml.indexOf("</ActionScriptVersion>"); | |
delta = xml.substring(from, to); | |
xml = xml.split(delta).join("<ActionScriptVersion>3"); | |
from = xml.indexOf("<AS3PackagePaths>"); | |
to = xml.indexOf("</AS3PackagePaths>"); | |
delta = xml.substring(from, to); | |
var classPath = "./"; | |
if (fileName.indexOf("/") > -1) | |
{ | |
classPath = ""; | |
var splitPath = fileName.split("/"); | |
splitPath.length--; | |
var i = splitPath.length; | |
while (i--) | |
{ | |
classPath += "../"; | |
} | |
} | |
xml = xml.split(delta).join("<AS3PackagePaths>" + classPath + "classes"); | |
FLfile.write(pPath, xml); | |
fl.getDocumentDOM().importPublishProfile(pPath); | |
fl.saveDocument( doc); | |
fl.getDocumentDOM().publish(); | |
FLfile.remove(pPath); | |
fl.closeDocument(doc); | |
exportlog+="updated and exported " + fileURI+"\r\n"; | |
} | |
} | |
function getFolderURIFromUser(){ | |
return fl.browseForFolderURL("Select folder to process"); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment