ByteArray Type Coercion failure when reading from

2019-05-30 17:11发布

问题:

I am reading in a ByteArray object from an ExternalInterface call which is obtaining the ByteArray from another SWF. The reason for the Javascript conduit is because the ByteArray data exceeds the 40k limit of the LocalConnection class.

I'm getting the following error:

TypeError: Error #1034: Type Coercion failed: cannot convert Object@d6f48e1 to flash.utils.ByteArray.

with this line of code:

swfBytes = ExternalInterface.call("getBytes", cacheIdx);

swfBytes is an initialized ByteArray object. I'm confident my call to getBytes() is returning a ByteArray object because if I run the following line of code, I get the number of bytes being passed.

ExternalInterface.call("getBytes", cacheIdx).bytesAvailable;

Any help is greatly appreciated.

回答1:

Thanks! Splitting the data into 40k chunks worked well. Now I have another issue, which is the inability to properly close and reuse the connection. Another answered question suggested using a unique connection string for each connection.