Embed="true" in <library> prevents me from using my .swf's movieclips, “AL lib: (EE) alc_cleanup: 1 device not closed” error


#1

Hi, I have a simple question, I need to access assets(movieclips) from an external .swf file & I use the embed=“true” in the tag to prevent my assets from being exposed on compile, the problem is when i do that I can’t use/access the .swf file’s contents using the methods explained in “Using swf assets” tuto, when I try to run it gives me the “AL lib: (EE) alc_cleanup: 1 device not closed” error with the window closing right after it appears when I run the project.
If I set it to false or omit it, everything works fine but the assets are exposed that way. So how do I access the movieclip assets from the .swf while embed=“true” ?
I’ve seen that there are @:bitmap, @:font, @:sound or @:file for using those kinds of embedded resources but there’s none for movieclips?
In case I can’t rely on the embed=“true” method, is there any other simple way to prevent my assets from being exposed at compilation/release? I’ve done a thorough searching in the forums & sites practically whole day yesterday without finding a solution to this other than trying to convert the assets into bytecode but I need a simpler/ready solution.
I’ve seen this issue being discussed since at least 2015 or even 2014 and now 3/4 years later there still isn’t a solution to that problem?
How do people actually publish their games using Openfl in this case if there’s no simple standard solution to protect their assets?


#2

The short answer? They don’t protect their assets. Whether you use Flash, OpenFL, Unity, or really anything else, your code and your art will be accessible to anyone motivated enough.

You can take steps to deter novices, but that’s about it.


#3

Yeah ik and thanks for the reply, deterring novices was about my intention, can you please hint me to that? Even if it requires coding like using ByteArrays as long as there’s a tuto or sample code of how to do it.


#4

To deter novices, you could encrypt the data beforehand and decrypt it at runtime. To make sure nothing is lost in translation, you probably want to use Haxe for both steps. That means you need a second OpenFL app that will process your assets before you compile your main app.

Use one of the symmetric encryption options. Don’t worry about choosing one that’s cryptographically secure; just pick the fastest. Its only job is to mix up the data enough that programs won’t automatically recognize the format.

There are some even simpler options you could try, but in those cases, programs might see right through it:

  • You could try deleting the file extensions and manually telling OpenFL how to interpret them. Problem is, modern browsers can see right through that sort of thing. If you make a PNG and change the extension to .jpg, your browser will display it anyway. It’ll even tell you that the image is really a PNG.
  • You could forget about cryptography and instead just compress your ByteArray. But if you save a file like that, it’s entirely possible that programs like 7-Zip will easily open it. (I’m actually not sure, but I wouldn’t be surprised.)

Anyway, back to encryption. Once you’ve encrypted, embedded, and decrypted the SWF, all you need to do is call new format.SWF(decryptedByteArray) and you’re good to go.

Two final notes:

  1. haxe-crypto and OpenFL each provide their own implementation of ByteArray. You’ll need to use toBytes() and fromBytes() to bridge the gap.
  2. Parsing the SWF at runtime means you’ll be missing out on some of OpenFL’s compile-time optimizations.

#5

Ok thanks for your reply, I’m not familiar with any of this so I’m not really sure if I’d be able to do it properly but I’ll try & do the research, in the meantime if there’s any tuto you know of that could help or speed things up please lemme know.


#6

The assets “pak” feature may also help. It could be modified to encrypt as well as packing assets


#7

I’m actually fine with just packing, in fact that’s the kind of thing I was looking for but I dunno why when I tried it before it didn’t generate the .pak for me but now that I tried again it just worked o_o might be cuz I didn’t try a Clean Build at that time before I added the -clean, just one thing please how do I access the content i.e movieclips from the .pak ? The setup is as follow:
I have 1 ForestCharacters.swf file in my assets folder, in my project.xml I have:
< library name=“ForestCharacters” type=“pak” />
< assets path=“assets/ForestCharacters.swf” library=“ForestCharacters” />
Then in the code:
Assets.loadLibrary (“ForestCharacters”).onComplete (function (library)
{
addChild(Assets.getMovieClip(“ForestCharacters:TurtleGolemSouthClip”) );
});
When I run the app, it shuts immediately with AL lib: (EE) alc_cleanup: 1 device not closed error.


#8

Ah, it might not be compatible with SWF yet. Maybe that was the issue


#9

Alright, but what about the embedding? isn’t there a way to access movieclips if we use embed=“true” in the library node like it’s possible for fonts, bitmaps or sounds via their resp. @tags?


#10

My objective is simply to make the frame png images in the bin/lib folder that were generated from the .swf file to be not directly visible in that form, kinda like what the pak feature does, I don’t really seek heavy encryption just something basic, same for sound files etc, is there any post or tool that does or explain how to do that please? This isn’t an issue when targeting the web platform but for desktop it’s quite a basic need.


#11

You can’t mix type “pak” with type “swflite” right now, but how we generate or how we parse the SWF output is certainly doable, but nothing I can clearly point to that would not require some work to do. I wonder if we could design a way to combine the two


#12

Ok thank you for the reply :slight_smile: