How asset packing might be added to the tools

This was originally a reply, but I’ve broken it into a new topic to make it easy to find :wink:

The tools have a different class, based on the target platform. For example, Windows builds are handled here:

If there was an asset packing solution, I would probably expect it could go in the AssetHelper class. On the update step (when files are copied) you can see it creates the asset manifest (with the list of all the asset files and IDs) here:

All the default assets are available to openfl.Assets using the DefaultAssetLibrary class:

This is what handles the “unpacking” of assets – how we go from “give me asset XYZ, please!” to having a real BitmapData instance. Instead of loading from disk, these could come from a big byte blob somewhere.

Some default packing mechanism would be very neat


Would you prefer packing everything into one file? or packing into individual files that have been sort of encrypted? The latter is easier…

Perhaps we need obfuscate or pack options, packing everything could be done without much changes, but packing into separate bundles would probably need a new attribute to assets, so we can decide how to bundle them in which separate files

can we bundle all assets into one file or several files depending on file types? provides a way to upload html5 game, but there’s a limit on number of files being uploaded.

Yes, you can try <library name="default" type="pak" />, and I think that should do it.

There’s also ways to use different asset libraries as well, if that makes things easier

getting below error when using the suggested library tag as above.

part of project.xml:

<!--The flixel preloader is not accurate in Chrome. You can use it regularly if you embed the swf into a html file
<!--or you can set the actual size of your file manually at "FlxPreloaderBase-onUpdate-bytesTotal"!-->
<app preloader="flixel.system.FlxPreloader" />

<!--Minimum without FLX_NO_GAMEPAD: 11.8, without FLX_NO_NATIVE_CURSOR: 11.2 -->
<set name="SWF_VERSION" value="11.8" />
<!--------------------------------WINDOW SETTINGS------------------------------->

<!--These window settings apply to all targets-->
	<!-- 640x416, 960x 624-->
<window width="640" height="416" fps="60" background="#000000" hardware="true" vsync="true" />

<window if="html5" width="0" height="0" resizable="true" fullscreen="true" />
<window if="desktop" orientation="landscape" fullscreen="false" resizable="true" />

<window if="mobile" orientation="landscape" fullscreen="true" width="0" height="0" />

<!--------------------------------PATHS SETTINGS-------------------------------->

<set name="BUILD_DIR" value="export" />
<classpath name="source" />
<assets path="assets" />
<assets path="assets/locales"  include="*.csv|*.xml"  />
<assets path="assets/fonts" include="*.ttf" embed="true"  /> 
<assets path="assets/gfx" include="*.png"  />
<assets path="assets/xml" include="*.xml"  />
<assets path="assets2" />
<assets path="assets2/data" include="*.tmx" />
<assets path="assets2/images" include="*.png" />
<assets path="assets2/sounds" include="*.ogg" />
<assets path="assets2/music" include="*.ogg" />

<haxelib name="hxcpp" version="3.4.64" />
<haxelib name="lime" version="2.9.1" />
<!-- this give C++ compilation issue <haxelib name="openfl" version="3.6.1" -->
<haxelib name="flixel" version="4.3.0" />
<haxelib name="firetongue" version="2.0.0" />
<!--In case you want to use the addons package-->
<haxelib name="flixel-addons" version="2.5.0" />
<haxelib name="flixel-ui" version="2.2.0" />
<haxelib name="extension-admob" version="1.6.4" />

<!--    <haxelib name="linden-google-iap" if="android" />	-->
<haxelib name="stablexui" version="1.2.1" />
<haxelib name="actuate" version="1.8.7" /> <!-- required by stablexui as well -->
<haxelib name="openfl" version="3.6.1" />
<!--In case you want to use the ui package-->
<!--<haxelib name="flixel-ui" />-->

<!--In case you want to use nape with flixel-->
<!--<haxelib name="nape" />-->


<!--Enable the Flixel core recording system-->
<haxedef name="FLX_RECORD"  />

<!--Disable the right and middle mouse buttons-->
<!--<haxedef name="FLX_NO_MOUSE_ADVANCED" />-->

<!--Disable the Native cursor api for Flash target-->
<!--<haxedef name="FLX_NO_NATIVE_CURSOR" />-->
<!--Optimise inputs, be careful you will get null errors if you don't use conditionals in your game-->
<haxedef name="FLX_NO_MOUSE" if="mobile"  /> 
<haxedef name="FLX_NO_KEYBOARD" if="mobile" />
<!-- below is required for mobile phone or TabletPC like Surface -->
<!-- <haxedef name="FLX_NO_TOUCH"  /> -->

<!--Disable the Flixel core sound tray-->
<!--<haxedef name="FLX_NO_SOUND_TRAY" />-->

<!--Disable the Flixel sound management code-->
<!--<haxedef name="FLX_NO_SOUND_SYSTEM" />-->

<!--Disable the Flixel core focus lost screen-->
<!--<haxedef name="FLX_NO_FOCUS_LOST_SCREEN" />-->

<!--Disable the Flixel core debugger. Automatically gets set whenever you compile in release mode!-->
<haxedef name="FLX_NO_DEBUG" unless="debug" /> 

<!--Enable this for Nape release builds for a serious peformance improvement-->
<haxedef name="NAPE_RELEASE_BUILD" unless="debug" />

<library name="default" type="pak" />
<!-- android specific -->
<!-- sdk 23 is required for extension-admob library -->
<android target-sdk-version="23" if="android" />

<!-- NMML reference: -->
<template path="PlatformConfigs/android/" rename="" if="android" /> 
<!-- -->
<template path="PlatformConfigs/android/AndroidManifest.xml" rename="AndroidManifest.xml" if="android"/>
<!-- same as certificate tag expect the console won't prompt you to enter keystore/alias password once you specify the password in>
<!-- <template path="release-key.jks" rename="release-key.jks"  if="android" unless="debug" /> -->

Running process: C:\Development\FlashDevelop-5.2.0\Tools\fdbuild\fdbuild.exe “C:\Projects\gaiaisland\gaiaisland.hxproj” -ipc 5415fbcc-45ec-40a3-87be-c761a1189875 -version “3.4.2” -compiler “C:\HaxeToolkit\haxe” -notrace -library “C:\Development\FlashDevelop-5.2.0\Library” -target "html5"
Building gaiaisland
Running Pre-Build Command Line…
cmd: “C:\HaxeToolkit\haxe/haxelib” run lime build “Project.xml” html5 -release -Dfdb
Called from ? line 1
Called from CommandLineTools.hx line 1400
Called from CommandLineTools.hx line 25
Called from CommandLineTools.hx line 125
Called from CommandLineTools.hx line 1279
Called from lime/project/ProjectXMLParser.hx line 21
Called from lime/project/ProjectXMLParser.hx line 54
Called from lime/project/ProjectXMLParser.hx line 1802
Called from lime/project/ProjectXMLParser.hx line 1267
Called from /usr/lib/haxe/std/haxe/xml/Fast.hx line 56
Uncaught exception - library is missing attribute path
Build halted with errors.

Hi, HaxeFlixel relies on an old openFL version (before 4.0 if I remember correctly) so you won’t be able to use this feature which is from openFL 7 I think