Skip navigation
Currently Being Moderated

Flash Pro CS6, JSFL, and SpriteSheetExporter.exportSpriteSheet()

Jul 17, 2012 6:14 PM

Tags: #jsfl #flash_cs6

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?

 
Replies
  • Currently Being Moderated
    Aug 7, 2012 8:21 AM   in reply to samahn

    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!

     
    |
    Mark as:
  • Currently Being Moderated
    Aug 8, 2012 1:51 AM   in reply to samahn

    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).

     
    |
    Mark as:
  • Currently Being Moderated
    Sep 3, 2012 9:14 PM   in reply to samahn

    I am also experiencing this error on a Mac. I was really looking forward to accessing this feature from JSFL.

     
    |
    Mark as:
  • Currently Being Moderated
    Sep 4, 2012 6:35 AM   in reply to samahn

    Hi,

    This seems to be an issue with the path param in SpriteSheetExporter.exportSpriteSheet() on Mac.. Will look into it.

     

    Thanks!

    Mohan

     
    |
    Mark as:
  • Currently Being Moderated
    Sep 5, 2012 2:02 PM   in reply to Mohanaraj CS

    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

     
    |
    Mark as:
  • Currently Being Moderated
    Sep 7, 2012 5:45 AM   in reply to BelayProductions

    Hello,

     

    Thank you so much for reporting this! This is certainly a bug on MAC, and we are investigating this on priority.

     

    Regards,

    Suhas Yogin

     
    |
    Mark as:
  • Currently Being Moderated
    Oct 15, 2012 10:20 PM   in reply to Suhas Yogin

    Any news on the issue? Or being able to generate the sheet with transparency?

     
    |
    Mark as:
  • Currently Being Moderated
    Oct 15, 2012 11:30 PM   in reply to onneponne

    I haven't heard anything new on this issue. I've long since given up assuming that Adobe gave us a sprite sheet generator that simply isn't capable of producing transparent backgrounds.

     
    |
    Mark as:
  • Currently Being Moderated
    Oct 17, 2012 3:47 AM   in reply to maki99

    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);

    }

     
    |
    Mark as:
  • Currently Being Moderated
    Oct 17, 2012 4:26 AM   in reply to aviPro

    Nice one, thanks! This one saved my day... The sprite sheet is generated as it should.

     
    |
    Mark as:
  • Currently Being Moderated
    Nov 15, 2012 7:14 PM   in reply to Suhas Yogin

    Any news regarding the argument error when exporting on a Mac?  Any workarounds or any other info?

     
    |
    Mark as:
  • Currently Being Moderated
    Nov 21, 2012 7:06 PM   in reply to Suhas Yogin

    Any updates on the issue?

    Will there be a patch, update or something?

    Planned release?

     

    Urgent please.

     
    |
    Mark as:
  • Currently Being Moderated
    Nov 22, 2012 2:48 AM   in reply to SomeGuyWithAMac

    did you try avipro's script? (commenting out the dir at the  //MAC)

     
    |
    Mark as:
  • Currently Being Moderated
    Nov 25, 2012 5:43 PM   in reply to onneponne

    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;

     
    |
    Mark as:
  • Currently Being Moderated
    Jan 3, 2013 5:59 PM   in reply to SomeGuyWithAMac

    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!

     
    |
    Mark as:
  • Currently Being Moderated
    Apr 5, 2013 10:45 PM   in reply to Suhas Yogin

    Hi,

    Do we have any update on mac bug ? Any news on this issue will be very helpful.

     
    |
    Mark as:

More Like This

  • Retrieving data ...

Bookmarked By (0)

Answers + Points = Status

  • 10 points awarded for Correct Answers
  • 5 points awarded for Helpful Answers
  • 10,000+ points
  • 1,001-10,000 points
  • 501-1,000 points
  • 5-500 points