|
-
self-portrait
[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?
-
5+5=55
Easiest way is to probably convert the ByteArrays into a .png... you'll get some automatic compression doing it that way too.
-
self-portrait
Oh cool, how would I do that?
-
5+5=55
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.
-
self-portrait
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!
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|