SWF Runtime loading - [ Cannot load file error ]


i am trying to load .bundle files at runtime but it is always giving me [ Cannot load file error ]

i am making bundle using openfl process TestGameLib.swf command.

var future = AssetLibrary.loadFromFile ("assets/libs/TestGameLib.bundle");
future.onError (library_onError);
future.onComplete (library_onComplete);

private function library_onError(err:Dynamic):Void
	trace("ERR "+err);

private function library_onComplete (library:AssetLibrary):Void
   	trace("Bundle Loaded");

I just gave it a try, and it is working here. Make sure your asset files are not embedded?

I ran openfl process path/to/NyanCat/Assets/library.swf path/to/TestProject/Assets/library.bundle, then used this code to run it


import openfl.display.Sprite;
import openfl.utils.AssetLibrary;

class Main extends Sprite {
	public function new () {
		super ();
		var future = AssetLibrary.loadFromFile ("assets/library.bundle");
		future.onError (this.library_onError);
		future.onComplete (this.library_onComplete);
	private function library_onError (err:Dynamic):Void {
		trace ("ERR "+err);
	private function library_onComplete (library:AssetLibrary):Void {
		trace ("Bundle Loaded");
		var clip = library.getMovieClip ("");
		this.addChild (clip);
<?xml version="1.0" encoding="utf-8"?>
	<meta title="HXSWFTest" package="com.sample.hxswftest" version="1.0.0" company="Company Name" />
	<app main="Main" path="Export" file="HXSWFTest" />
	<source path="Source" />
	<haxelib name="openfl" />
	<assets path="Assets" rename="assets" embed="false" />
1 Like

thanks i was missing this embed="false".

can i unload this too ?

I have another question regarding project.xml :
just dont want to spam so asking it here :smiley:
when i see my bin folder it shows me some assets copied twice:

<assets path="assets/preloader" rename="preloader" embed="true" />
<assets path="assets/fonts" rename="fonts" embed="true" />
<assets path="assets/data" rename="data" />
<assets path="assets/sounds" rename="sounds" />	

<assets path="assets" rename="assets" embed="false" />

is there something wrong i am doing here or it is just a normal behavior

Bin Folder

Assets folder


Your last tag is including your same paths a second time:

<assets path="assets" rename="assets" embed="false" />

You could either A.) remove it, or try adding exclude filters :slight_smile:

<assets path="assets" rename="assets" exclude="preloader || fonts || data || sound" embed="false" />
1 Like