EmbedAssets haxelib released:

110 views
Skip to first unread message

ProG4mr

unread,
Aug 15, 2012, 1:57:54 PM8/15/12
to haxe...@googlegroups.com
Hey, i just got haxe round-up and noticed i forgot to publicize the library i released a couple of days ago:

EmbedAssets -> Allows you to store assets inside your code and retreive them as Bitmaps, Text, or ByteArray
the same way you do with nme.Assets.


Hope more ppl find use to that,
the lib is still missing Font and Sound assets, anyone knows how these can be created from bytearrays? 

j...@justinfront.net

unread,
Aug 15, 2012, 2:05:24 PM8/15/12
to haxe...@googlegroups.com
Oh I moved my byexample page and have not refixed it, but you can see cache here

Ashiq A.

unread,
Aug 15, 2012, 2:06:20 PM8/15/12
to haxe...@googlegroups.com
I looked at the github docs. Some questions/comments that come to mind:

- Shouldn't "IMAGE", "TEXT", and "BYTES" be an enumeration instead of a string? Do you get an exception if you pass in an invalid value?
- Why do you have an image key? Wouldn't you want to just use the path? (Or are you catering for a use-case where the resource filename itself will change, and using keys means you won't have to change your code?)
- What's the benefit of embedding, anyway?

I'm using NME, so for me, point #3 is an interesting one -- is it that Haxe is missing this functionality?

--Ashiq


ProG4mr

unread,
Aug 15, 2012, 2:18:59 PM8/15/12
to haxe...@googlegroups.com
Thx JLM it may just work, i really needed that.

Hey ashiq i didnt used enumerators or anyother type because it was the first time i used macros and that was the solution i got working, maybe it works with enums, honestly im not sure. About embeding assets, the advantage is that the assets are hidden inside your code and adds some protection / privacy when you export your app, it also allows to use compression algorithms and encription more easly since the assets are serialized.

Joshua Granick

unread,
Aug 15, 2012, 3:01:49 PM8/15/12
to haxe...@googlegroups.com
Would it be beneficial for this kind of functionality to be directly integrated into the NME command-line tools and nme.Assets class?

I had thought that we could write all the files to one big blob of an assets file (like "assets.dat" or something) and remember the start and end positions. Then it would be a matter of having nme.Assets stream that portion of bytes rather than fetching the file from disk.

If it were automated in this way, it would be transparent to the application code (Assets.getBitmapData like normal) but instead could be an option in your NMML, like <assets path="Assets" rename="assets" include="*" embed="true" />

ProG4mr

unread,
Aug 15, 2012, 3:16:21 PM8/15/12
to haxe...@googlegroups.com
That would be really nice, but a bit out of my league atm, best i could do would be implement that "blob" using the same haxelib and macros (nothing too hard) but still it would have 2 problems:

- Dont know how to convert Bytearray to Font or Sound Class (JLM gave me a clue on that to see later).
- No direct implementation from nmml (like i said im too fresh to even have looked at nme repository).

Reason i wrote this lib is because i really need to embed assets to prevent clients from extending / modifing an editor i wrote back in flash, now im already porting it to haxe + nme + aswing, so yes its a "must have" feature if you ask me ^^.

Ashiq A.

unread,
Aug 15, 2012, 4:09:16 PM8/15/12
to haxe...@googlegroups.com
Thanks for the information. Looks like a pretty decent library :)

Cheers,

--Ashiq

j...@justinfront.net

unread,
Aug 15, 2012, 4:45:03 PM8/15/12
to haxe...@googlegroups.com

On 15 Aug 2012, at 18:57, ProG4mr wrote:

> the lib is still missing Font and Sound assets, anyone knows how
> these can be

I once got a logo out of a swf embeded as a bytearray in haxe flash, I
posted to the old haxe list I guess you could just store fonts in
swf's as byte in string rather than byte array, I can look for the
thread later if it's useful, but maybe it's not the best way with
format tools there must be better way, if in doubt try asking Jan on
the IRC

;J

ProG4mr

unread,
Aug 15, 2012, 5:54:20 PM8/15/12
to haxe...@googlegroups.com
I store fonts as bytearray, problem is turning it back into Font format, maybe a cast(bytearr, Font) will work? Im not too positive about that.
Reply all
Reply to author
Forward
0 new messages