Hi, I've been trying to use SpriteSheetExporter.exportSpriteSheet() but it just reports the following error: "Argument number 1 is invalid"
The documentation says to pass a (file) path for the first argument. I've tried to pass both a platform path and a URI to a file to the method without success.
The documentation seems to need some clean up too:
http://help.adobe.com/en_US/flash/cs/extend/WSd5f4b6c52cfaa4b1-d343196 1351cb0528c-7ffb.html
Anyone have a working example?
Hi,
I'm not sure right now what would generate the exact error you refer to, but here's an example of an exportSpriteSheet() call that works for me:
spSheet.exportSpriteSheet("file:///C|/target/spritesheet" ,"PNG",true);
spSheet is a SpriteSheetExporter instance. This call will create the following file: C:\target\spritesheet.png
Pls let me know if you have any luck with this. Especially if you are able to generate a png image with a transparent background... ![]()
Cheers!
Bummer.
Here's a piece of code that works for me.
Run it on a flash document with a movieclip named "Anim" in the library. Also, you'll need to modify the dir variable as described in the inline comment below.
fl.getDocumentDOM().library.selectItem("Anim");
var item = fl.getDocumentDOM().library.getSelectedItems()[0];
fl.trace ("Item to export: " + item.name);
var dir = "file:///C|/target/"; //The directory where the image file should be created. This directory must exist - modify as needed.
if(FLfile.exists(dir)){
var uri = dir + "anim";
var sse = new SpriteSheetExporter();
sse.layoutFormat = "easeljs";
sse.addSymbol(item);
var output_data = sse.exportSpriteSheet(uri ,"PNG",true);
fl.trace("output_data :"+output_data);
} else {
fl.trace ("Error: Folder does not exist: " + dir);
}
If this doesn't work for you my guess is that your problem is mac specific (I'm on a PC).
I switched over to my Windows machine last night, and tested this, and I can confirm that it works under Windows, but not under OS X. The code I used is based on maki99's:
fl.getDocumentDOM().library.selectItem("BarnWithDoorsAnimated");
var item = fl.getDocumentDOM().library.getSelectedItems()[0];
fl.trace ("Item to export: " + item.name);
var dir = "file:///C|/Users/xxxx/Documents/sprite-sheet-test/";
//var dir = "file:////Users/xxxx/Documents/sprite-sheet-test/";
if(FLfile.exists(dir)){
var uri = dir + "anim";
var sse = new SpriteSheetExporter();
sse.layoutFormat = "easeljs";
sse.addSymbol(item);
var output_data = sse.exportSpriteSheet(uri ,"PNG",true);
fl.trace("output_data :"+output_data);
} else {
fl.trace ("Error: Folder does not exist: " + dir);
}
BTW - on the Mac, I tried "file:/Users/..." (which said file does not exist), as well as "file://Users/...", "file:///Users/...", and "file:////Users/...", all of which gave me the error with argument 1. It's kind of difficult to find documentation on how these URLs are supposed to be formatted...
Brian
Try this ?
fl.getDocumentDOM().library.selectItem("symbolname");
var item = fl.getDocumentDOM().library.getSelectedItems()[0];
fl.trace ("Item to export: " + item.name);
//var dir = "file:///Users/xxx/Documents/sprite-sheet-test/"; //MAC
//var dir = "file:///C|/xxx/sprite-sheet-test/"; //WINDOWS
if(FLfile.exists(dir)){
var uri = dir + "symbolname";
var sse = new SpriteSheetExporter();
sse.layoutFormat = "eseljs";
sse.addSymbol(item);
var output_data = sse.exportSpriteSheet(uri ,{format:"png", bitDepth:32, backgroundColor:"#00000000"})
fl.trace("output_data :"+output_data);
} else {
fl.trace ("Error: Folder does not exist: " + dir);
}
onneponne wrote:
did you try avipro's script? (commenting out the dir at the //MAC)
At line 12 of file "/Applications/Adobe Flash CS6/Common/Configuration/Sprite Sheet Plugins/Starling.plugin.jsfl": exportSpriteSheet: Argument number 1 is invalid.
And line 12 of the file looks like this:
pluginInfo.capabilities.canRotate = false;
Same problem here. Mac OS X 10.8.2, Flash Pro CS6 12.0.2.529.
I've tried passing valid paths using valid URI, platform path, relative path, w or w/o file name and extension... all result in the same exception being thrown:
exportSpriteSheet: Argument number 1 is invalid.
var document = fl.getDocumentDOM();
var timeline = document.getTimeline();
var fileName = document.name.replace(/\.[^\.]+$/, '');
var fileDir = document.path.replace(/[\/\\][^\/\\]+$/, '');
var item = document.library.getSelectedItems()[0];
var spriteName = item.timeline.name;
var exportDir = FLfile.platformPathToURI(fileDir); //+'/../../app/data/scenes');
var format = {format:"png", bitDepth:32, backgroundColor:"#00000000"};
var writemeta = false;
var sse = new SpriteSheetExporter();
sse.addSymbol(item);
sse.layoutFormat = "easeljs";
var path = spriteName +'.png';
path = exportDir +'/'+ path;
//path = FLfile.uriToPlatformPath(path);
fl.trace('export '+ item +' using '+ sse +' to '+ path);
var result = sse.exportSpriteSheet(null, format, writemeta);
fl.trace('result: '+ result);
Please fix!
North America
Europe, Middle East and Africa
Asia Pacific