first of all thank you for great work on the library. It is real pleasure to work in it.
But from time to time (new versions of libraries?) something is wrong.
Now, when I try to load swf assets with this code:
Assets.loadLibrary("assets/library.swf", function (_) {
var r = Assets.getMovieClip("library:Rect");
addChild(r);
});
i get this error (flash compilation):
ReferenceError: Error #1065: Zmienna JSON nie została zdefiniowana.
at lime::Assets$/loadLibrary()
at openfl::Assets$/loadLibrary()
at ApplicationMain$/init()
at lime.app::Preloader/start()
at openfl.display::Preloader/display_onComplete()
at flash.events::EventDispatcher/dispatchEventFunction()
at flash.events::EventDispatcher/dispatchEvent()
at NMEPreloader/onLoaded()
at openfl.display::Preloader/start()
at lime.app::Preloader/current_onEnter()
You need to either create a local anonymous function like @singmajesty wrote: Assets.loadLibrary ("librarySwf", function (_) { /* body here */ });
or pass a function: Assets.loadLibrary ("librarySwf", myFunction);
Thanks, yeah I eventually figured out the code change and the need to use > function in the first option, not the function name as I had previously used…
The reason for the search was I had already been using the 2nd option, but with the latest lime updates trying to recompile the output was now broken throwing the error…
openfl.AssetLibrary -> Void should be lime._Assets.LimeAssetLibrary -> Void
Is it still possible to pass a function and assign a variable to the call back for later use?
I would recommend using an underscore _ instead of handling the library value for now, or if you must handle the library, using Dynamic as the type, this is something I’m going to have to look into. You can use <library path="to/file.swf" preload="true" /> now to preload your library, of all choices, that might be the very easiest one – it calls loadLibrary for you
Just for the record, there’s nothing special about using an underscore as an argument. You know how you can start variable names with an underscore, right? This is just a degenerate case where you start with an underscore and don’t add any more characters.
If you check the inferred type using $type(_);, you’ll get “Unknown<0>,” just like if you named it anything else.
It is real syntax for ignoring a value when you are writing a switch case, and I think maybe in some other places. As its used there clearly for ignoring a value, I think it’s good convention elsewhere