1

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

MuertoExcobito
  • 9,741
  • 2
  • 37
  • 78
Fred
  • 347
  • 3
  • 11
  • Error 2015 might be caused by zero width or height of the `BitmapData` – www0z0k Aug 07 '16 at 20:24
  • Check if you don't go out of memory. – Vesper Aug 07 '16 at 21:43
  • Does it work if you don't involve Scaleform? Using just AS3 code to declare `var displayBmp : BitmapData;` and `var scratchBmp : BitmapData;` I could then use your shown code to clone without issues. Even traced `scratchBmp.width` as 200. Maybe you should post a **complete yet minimal** code for us to test/recreate your issue. – VC.One Aug 08 '16 at 00:27
  • Everything works without scaleform. Width and Height have been tested as mentioned above, which was sufficient for causing the crash. – Fred Aug 08 '16 at 06:41
  • Sorry buddy, I read too fast last time. No clue then. If it was my problem I'd be trying example `new BitmapData(200, 200, false, 0xFF0000);` just to be sure that between your shown `transparency=true` & color hex of `0` it's not making an empty bitmapdata with no pixels to clone. At least try `displayBmp.draw(something);` before using `.clone`. If still invalid data after `.draw`ing then you have an issue elsewhere... – VC.One Aug 08 '16 at 21:54
  • @VC.One Just doing: var displayBmp:BitmapData; displayBmp = new BitmapData(200, 200, false, 0xFF0000); displayBmp.draw(this); Was enough to make it throw the error. Works just fine in the Animate Debugger. – Fred Aug 09 '16 at 06:43
  • Since it works fine in Flash Player (debugger), can you confirm that Scaleform itself actually supports any bitmapData API methods? Check its documentation... – VC.One Aug 09 '16 at 07:26
  • @VC.One I can't find the document for the version I have, and nobody seems to know. – Fred Aug 09 '16 at 14:26
  • In my experience, if cloning bitmapdata works in the IDE but not in the player, you may have a security issue. It depends on where the image data is coming from. Images from external domains cannot be cloned. – Kokodoko Aug 10 '16 at 11:43

1 Answers1

1

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.

MuertoExcobito
  • 9,741
  • 2
  • 37
  • 78
  • Thanks for the reply, very appreciated. How would I go about Initializing a RenderThread class ín order to pass it on to the HAL constructor, can't find any documentation on that. – Fred Sep 06 '16 at 15:30
  • 'RenderThread' class isn't really required. You could reuse the ones in the samples (in Src/Platform), if you wanted. If you're integrating it a multi-threaded rendering application, you only need to provide an implementation of ThreadCommandQueue. If you are single threaded, you can use SingleThreadedCommandQueue (http://help.autodesk.com/view/SCLFRM/ENU/?guid=__cpp_ref_06044_html). – MuertoExcobito Sep 06 '16 at 15:46
  • I can't Create an instance of ThreadCommandQueue as the class is practically empty. No way to initialize or implement in any way. I dont have the SingleThreadedCommandQueue either. – Fred Sep 07 '16 at 11:16
  • SingleThreadedCommandQueue is provided in later versions of the SDK. You do not instantiate ThreadCommandQueue directly, you must implement a derived class. – MuertoExcobito Sep 07 '16 at 12:56
  • Could you post a example of what you mean? I have never really worked on the Code Part of Scaleform. Thanks – Fred Sep 09 '16 at 09:21