Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/tiagolr/embedassets
[deprecated] Haxelib utility for embed assets.
https://github.com/tiagolr/embedassets
Last synced: about 2 months ago
JSON representation
[deprecated] Haxelib utility for embed assets.
- Host: GitHub
- URL: https://github.com/tiagolr/embedassets
- Owner: tiagolr
- Created: 2012-08-11T23:42:00.000Z (over 12 years ago)
- Default Branch: master
- Last Pushed: 2014-07-05T01:55:59.000Z (over 10 years ago)
- Last Synced: 2023-03-27T08:50:21.973Z (almost 2 years ago)
- Language: Haxe
- Homepage:
- Size: 116 KB
- Stars: 8
- Watchers: 6
- Forks: 5
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# DEPRECATED
**Can be used as old macro reference tho**
# EmbedAssetsEmbedAssets is an haxe nme tool that allows you to store external assets inside the binaries at compile-time using macros, and retreive them at run-time.
____________### Suported asset types:
Files of any type can be embed in the compiled code. They can be retreived as:
- BitmapData - using "IMAGE" as serialize() argument. (use this for png, jpeg or gif).
- String - using "TEXT" as serialize() argument. (use this for anyfile you want to retreive as a string).
- ByteArray - using "BYTES" as type argument for serialize method. (use this for anything else).
### Usage example:
```text
// Assets serialization
private function init() {
EmbedAssets.serialize("images/test.png", "IMAGE", "ImgFirst");
EmbedAssets.serialize("images/this.png", "IMAGE", "ImgSecond");
EmbedAssets.serialize("images/oOoO.png", "IMAGE", "ImgThird");
EmbedAssets.serialize("images/readme.txt", "TEXT", "TxtReadme");
EmbedAssets.serialize("images/config.xml", "TEXT", "TxtConfig");
EmbedAssets.serialize("images/flashr.swf", "BYTES", "BTEmbedSwf");
Lib.stage.addEventListener("ASSETS_LOADED", onAssetsLoaded);
EmbedAssets.init();
Resources.init();
}
private function onAssetsLoaded(e:Event):Void
{
addChild(new Bitmap(Resources.getBitmapData("ImgFirst")));
addChild(new Bitmap(Resources.getBitmapData("ImgSecond")));
addChild(new Bitmap(Resources.getBitmapData("ImgThird")));
trace(Resources.getText("TxtReadme"));
trace(Xml.parse(Resources.getText("TxtConfig"));
var swf:ByteArray = Resources.get("BTEmbedSwf");
}
```
- Files are stored at compile-time using EmbedAssets.serialize() method.
- Files can be retreived from Resources class using getBitmapData(), getText() or getBytes() method (like mne.Assets).
- More information one the arguments are availibe in the sc.
### Notes:
- For now there is no support for Sound or Font types, let me know if you figure how they can be created from bytearrays.