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 intoMovieDef::CreateInstance
as the last parameter, and BitmapData operations are used on the first frame. Without an instance of theThreadCommandQueue
, 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 storeThreadCommand
objects in a (thread-safe) list, when called fromPushThreadCommand
, and callExecute
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 usingMovie::Advance
andHAL::Display
on the same thread. You can see a more complex version of aThreadCommandQueue
implementation, used in the Scaleform samples from theRenderHALThread
class, which defers most of the important implementation toRTCommandQueue
.