A Flash Developer Resource Site

Results 1 to 5 of 5

Thread: [disc] Embeding external resources

  1. #1
    self-portrait Kianis's Avatar
    Join Date
    Feb 2004
    Location
    Stockholm, Sweden
    Posts
    425

    [disc] Embeding external resources

    When developing I prefer to keep my resources external (graphics, levels, music etc)
    but when it comes to delopying it is so much easier to have everything
    embeded into a single swf-file (for most sites this is the only option).

    So, how do you embed your data? Graphics and sound are of course
    very easy, as they are recognized by the Flash IDE, but how would
    you go about to embed xml-data or byteArrays? I'd hate to have to
    host them on my site.
    Are there no clever ways? I suppose I could have my xml in a string,
    but what about byteArrays? Any ideas?
    // Mazapán, my portfolio

  2. #2
    5+5=55 Schfifty Five's Avatar
    Join Date
    Jun 2006
    Posts
    698
    Easiest way is to probably convert the ByteArrays into a .png... you'll get some automatic compression doing it that way too.

  3. #3
    self-portrait Kianis's Avatar
    Join Date
    Feb 2004
    Location
    Stockholm, Sweden
    Posts
    425
    Oh cool, how would I do that?
    // Mazapán, my portfolio

  4. #4
    5+5=55 Schfifty Five's Avatar
    Join Date
    Jun 2006
    Posts
    698
    Googling it might give you some examples of how to store data in a png. You could probably just make your own script to do it pretty easily. Create a new BitmapData object and then fill each pixel with the bytes in your ByteArray (3 bytes per pixel). Then the simplest way would probably be to attach it as a Bitmap on the screen, use Print Screen, and save the bitmap as a .png and add it to your library. Then you can load the .png and get back the ByteArray by going through the pixels one by one and putting the data into your ByteArray. Make sure you have the export settings on "Lossless" and not JPG though.

    Sorry about the crappy explanation, someone else might be able to help you out a bit more.

  5. #5
    self-portrait Kianis's Avatar
    Join Date
    Feb 2004
    Location
    Stockholm, Sweden
    Posts
    425
    Thanks for the answer! There's even methods to create bitmapdatas directly from a byteArray and vice versa. How lazy of me not checking the livedocs
    properly!
    // Mazapán, my portfolio

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  




Click Here to Expand Forum to Full Width

HTML5 Development Center