Scaleform BitmapData: Invalid Bitmapdata

260 Views Asked by At

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

1

There are 1 best solutions below

5
On

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.