Created
August 25, 2011 09:48
-
-
Save davestewart/1170345 to your computer and use it in GitHub Desktop.
Make Animation: Imports a sequence of png files and exports an SWF
This file contains hidden or 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
/** | |
* 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