관리 메뉴

180bpm

PNG2SWF.jsfl 본문

Flash/기타

PNG2SWF.jsfl

powdersnow 2012. 3. 26. 20:26
반응형
/*
*
*  FOLDER_PNG2SWF JSFL v1.2
*  by Mr.doob
*  스테이지 배경 손 보고, 강제로 스무싱이랑 PNG 설정으로 저장되게 수정
*  fl.createDocument();를 사용하면 무조건 AS3으로 생성되기 때문에 AS2로 바꿔주는 작업
*/

script();

function script()
{
var folderURI = fl.browseForFolderURL("Select the folder with the PNG files.");

if (folderURI == null)
return;

var folderContents = FLfile.listFolder(folderURI);

//var jpeg_quality = prompt("JPEG Quality?", "85");
//var allowSmoothing = confirm("Bitmap smoothing?");
//var securityAllowDomain = confirm("Add Security.allowDomain(\"*\") code?");

for(var i = 0; i < folderContents.length; i++)
{
var pngURI = folderURI + "/" + folderContents[i];

if (pngURI.substr(pngURI.length-4) != ".png")
continue;

//fl.trace("OPEN - " + folderContents[i]);

var doc = fl.createDocument();
var profileXML=fl.getDocumentDOM().exportPublishProfileString('Default'); 
//액션 버전 바꿔주는 구문 
var newProfileXML = profileXML.replace("<ActionScriptVersion>3</ActionScriptVersion>", "<ActionScriptVersion>2</ActionScriptVersion>"); 
fl.getDocumentDOM().importPublishProfileString(newProfileXML);
doc.backgroundColor = '#FFFFFF';
doc.importFile(pngURI);
var bmp_lib = fl.getDocumentDOM().library.items[0];
//if (allowSmoothing)
bmp_lib.allowSmoothing = true;

//bmp_lib.quality = Number(99);
bmp_lib.compressionType = "lossless";
//if (securityAllowDomain)
// fl.getDocumentDOM().getTimeline().layers[0].frames[0].actionScript = 'Security.allowDomain("*");';
var bmp_tl = fl.getDocumentDOM().getTimeline().layers[0].frames[0].elements[0];
doc.width = Math.floor(bmp_tl.width);
doc.height = Math.floor(bmp_tl.height);
var swfURI = pngURI.substr(0,pngURI.lastIndexOf(".")-3)+"";
doc.exportSWF(swfURI, true );
doc.close(false);
//fl.trace("4");
//fl.trace("COMPLETE - PNG: " + FLfile.getSize(pngURI) + ", SWF: " + FLfile.getSize(swfURI) + " - Compression: " + Math.floor((FLfile.getSize(swfURI) / FLfile.getSize(pngURI))*100) + " %");
}
}
반응형
Comments