Skip to content

Instantly share code, notes, and snippets.

@davestewart
Created August 25, 2011 09:48
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save davestewart/1170345 to your computer and use it in GitHub Desktop.
Save davestewart/1170345 to your computer and use it in GitHub Desktop.
Make Animation: Imports a sequence of png files and exports an SWF
/**
* Make Animation
* Imports a sequence of png files and exports an SWF
* @author Dave Stewart
* @see www.xjsfl.com
*/
function makeAnimation()
{
var folder = fl.browseForFolderURL();
if(folder)
{
// create documnet
fl.createDocument();
// variables
var dom = fl.getDocumentDOM();
var tl = dom.getTimeline();
var lib = dom.library;
var files = FLfile.listFolder(folder, 'files');
// ensure only png files
files = files.filter(function(file){ return /\.png$/.test(file); });
// import loop
for(var i = 0; i < files.length; i++)
{
var uri = folder + '/' +files[i];
fl.trace('Importing: ' + FLfile.uriToPlatformPath(uri));
tl.currentFrame++;
document.importFile(uri);
if(i < files.length - 1)
{
tl.insertBlankKeyframe();
}
}
// adjust document size
dom.selectAll();
var size = dom.getSelectionRect()
dom.width = parseInt(size.right);
dom.height = parseInt(size.bottom)
// export and close
dom.exportSWF(fl.browseForFileURL('save'));
fl.closeDocument(dom);
}
}
makeAnimation();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment