For the following C++ and ActionScript3 code, my AIR application crashes when the getBytes2 method is called. Why is this happening? Solution suggestions would be appreciated.
C++ Code:
FREObject getBytes2(FREContext ctx, void* funcData, uint32_t argc, FREObject argv[])
{
FREObject result;
FREByteArray actualBytes;
FREAcquireByteArray(argv[0], &actualBytes);
uint8_t* nativeString = (uint8_t*) "Hello World from C++";
memcpy(actualBytes.bytes, nativeString, sizeof(nativeString));
FREReleaseByteArray(&actualBytes);
FRENewObjectFromBool(1, &result);
return result;
}
ActionScript3 Code:
public function getBytes2():ByteArray {
var ba:ByteArray = new ByteArray();
this._ExtensionContext.call("getBytes2", ba);
ba.position = 0;
return ba;
}
See FREImageProcessor.cpp for a working example of dynamically setting the length. Basically you set the length the same way you would in ActionScript.