Have Adobe changed Flash's ExternalInterface marshalling? - actionscript-3

I have an application written in ActionScript 3 which has to run on all versions of the Flash runtime, including the latest - Flash 18.
One section of my code passes a rather complex object (actually a tree of objects) from AS3 to JS via ExternalInterface.call(). The object has internal cyclic references, and it always used to work, up to and including Flash version 17.
In Flash 18 this object no longer gets passed, there is a very long pause, and a stack overflow is thrown. Upon further inspection (with the debugger and FlashBuilder) I find that the pause is in a toJSON method getting called recursively (obviously not correctly handling the cycles in my object).
The documentation for ExternalInterface states that marshalling is done using XML and in the past I've had problems when I've tried to marshal data that can't be represented easily in XML but would work in JSON, I now appear to be having the opposite issue, and this is quite a backward step if cyclic references in existing compiled applications will now break.
Has anyone else seen this issue?
Do we know if this is intentional, permanent, and/or documented? It doesn't appear in the release notes for Flash 18, so far as I can see.

Related

ExternalInterface escapes strings using JSON conventions

I'm getting hundreds of lines in my trace log per second!
WARNING: For content targeting Flash Player version 14 or higher, ExternalInterface escapes strings using JSON conventions. To maintain compatibility, content published to earlier Flash Player versions continues to use the legacy escaping behavior.
I already found a question on how to prevent this warning. However, I'm using SWC libraries for my SWF. So I don't have their source code. I need a way to suppress this warning. I don't mind turning all warnings/errors off for this SWF. Is there a way to stop it?
Try add debug=false to compiler options.

Scaleform BitmapData: Invalid Bitmapdata

I'm trying to add a "on fire effect" to our UI.
I am achieving this using BitmapData and PerlinNoise and some others.
The issue comes when anything I do with the BitmapData causes this error:
ArgumentError: Error #2015: Argument error: Invalid BitmapData.
at effects::FireFX/updateBitmaps()...
Something as simple as this will cause the error to show up.
displayBmp = new BitmapData(200, 200, true, 0);
scratchBmp = displayBmp.clone();
In my case, functions like clone() or perlinNoise() or colorTransform.... etc... are causing the crash.
Debugging / Running it under Animate CC works just fine.
PD: Publishing to Flash 10.3, using Scaleform: 4.1.19
Thanks
Scaleform does support the BitmapData API, as of version 4.1 (reference). However, 4.1.19 was the first release of 4.1, and thus the initial release with BitmapData support. You may want to upgrade to a newer version, as there have certainly been fixes to the BitmapData support since its initial release.
The most common reason to get this error, is to not pass a ThreadCommandQueue instance into MovieDef::CreateInstance as the last parameter, and BitmapData operations are used on the first frame. Without an instance of the ThreadCommandQueue, the renderer cannot create the backing for the BitmapData objects within Scaleform. A more descriptive warning was added to Scaleform in later versions.
For ThreadCommandQueue, you generally need to implement this yourself, to integrate properly with your application's rendering code. The simplest multi-threaded implementation would simply store ThreadCommand objects in a (thread-safe) list, when called from PushThreadCommand, and call Execute on the objects at some point during the application render loop.
In later versions of the SDK, there is a class provided called SingleThreadedCommandQueue, which provides an basic implementation that will execute all commands immediately. This only works if you are using Movie::Advance and HAL::Display on the same thread. You can see a more complex version of a ThreadCommandQueue implementation, used in the Scaleform samples from the RenderHALThread class, which defers most of the important implementation to RTCommandQueue.

Unity C# JSON Library without Exceptions

My team is currently using Boomlagoon's JSON library. The problem is that we ship the game with "fast but no exceptions" turned on (like most recommend to do), so if there is a JSON error the app will crash. The JSON string we are deserializing is from a server, which is why it is not necessarily trustworthy. Simply wrapping JSONObject.Parse in a try/catch would actually by sufficient for our needs (it is fine to ignore a broken response, and all we care about is not CRASHING). However, since exceptions are turned off, this can no longer be relied upon. The only solution we can think of is to write a JSON-verifier (e.g. if (JSON.verify(string)) JSONObject.Parse(string) ), which starts to just look like writing our own JSON parse at that point. Is there an alternative strategy or perhaps a JSON library out there that uses error objects instead of exceptions?
If not mistaken: http://james.newtonking.com/json would do the validating,
it is open source and written in c# wrap it in a plugin and throw in a plugin folder in unity and you will have a validator.

Word-VBA Functions "Method Saveas2 of object failed"

I have an access-vba application that also makes use of word-vba. While running the application on my local machine, it functions well. Once it is moved to others (same versions of access and word) it will crash when it comes to the vba portion of word. Commands such as document.open or .saveas2 fail: Method 'SaveAs2' of object failed for example.
I've also noticed that libraries that I've referenced in the application are required by any other end user. I'm used to just compiling with the libraries and from that point they are always included in the .jar/.exe/etc, but, it seems when you move the application to other's computers it's always trying to recompile?
I'm not well versed in VBA so I'm speculating that my failing word-vba functions are because of a referencing error, any other ideas?
The "libraries" that VBA can reference are actually COM objects, usually packaged as DLL files. They are objects which are dynamically instantiated at runtime (if they aren't already) when requested. They are loaded by Windows into memory and your program uses the COM standard to interact with them, calling methods and getting or setting properties (interprocess communication). There are generally two ways of interacting with them: early binding and late binding.
With early binding, you add a reference to the library while you are still writing code, which allows the VBA IDE to provide autocompletion and some compile-time error checking. You instantiate objects with the "new" keyword and by directly typing the object name. However, early binding requires that you select a specific dll and possibly a specific version of the interface. This can lead to issues if you reference a specific interface version which one of your users doesn't have.
With late binding, you instantiate objects using CreateObject or GetObject, requesting them by name from Windows. Windows will look the name up and return a reference to the object. The variables in your code are simply objects and calling methods is a bit dangerous because the compiler allows you to type in whatever method name you want and provides no compile-time warnings. This has the advantage that as long as you are calling well established methods and nothing new or deprecated, the code will work regardless of the user's version.
As for the error you are getting, you may want to check the version of Office on the user machines - SaveAs2 was added in Office 2010.

Is it possible to write an AS3 library with Haxe that uses type parameters?

First a little background: I'm looking for a way to create a "collection" library that abstracts the Flash Player version based implementation (Vector on FP10, Array on FP9) away from the calling code. I've already written a small AS3 lib doing that but...
...the performance is bad (especially because of two levels of indirection and the runtime type checks on the Array implementation)
...the code is ugly (since Vector types need to be defined at compiletime I needed a factory returning concrete Vector instances based on an Enum that contains only the supported types)
I'm currently looking into Haxe as a possible solution since it supports type parameters and is able to compile to various Flash Player versions (and apparently compiles into mmore optimized bytecode).
Now, my question is: Is there a way to write a library in Haxe that can be used like this in AS3 code
var foo:IMyInterface = new MyImplementation(int);
var bar:IMyInterface = new MyImplementation(getDefinitionByName("my.package.MyClass"));
with IMyInterface exposing the required methods (push, pop, ...)?
The basic idea is that I want to provide the type information at runtime and get a typesafe Flash Player version independent "collection" for use in the calling code without having to bother with conditional compilation fragments all over the place.
Can Haxe do something like that and if yes, how can I make it work?
There's an opportunity in Haxe to override native classes (e.g. int) in Haxe. take a look at the Metadata manual. Metadata has been added in version 2.06.
As for analogue of getDefinitionByName() method. Take a look at resolveClass() method of the Type class.