Intro to AS3 Workers (Part 4): Fixes for the Release Player

I had intended my previous post to be the final in the AS3 Workers series, but Adobe has made some last-minute changes in the 11.4 Player that I need to address.

Specifically, they have pushed back support for ByteArray.shareable to Player 11.5 / AIR 3.5 citing last minute bug reports. This means that you must manually share the ByteArray, and it also means that 2 of my demo’s have broken!

The Fix

The only difference is that instead of just sharing the ByteArray in our Init , and then relying on it to be shared, we must manually share it each time it gets changed.

There’s 2 ways to do this:

  • messageChannel.send(byteArray)
  • worker.setSharedProperty(“byteArray”, byteArray);

Beyond that all code can stay the same. We can retain our fast serialization method of packing everything into a ByteArray, as it’s still the quickest way to transfer data.

The downside here now is that the memory must actually be transferred from Worker to Main Thread, this will incur some performance penalties, but I’m not sure to what extent, or in what Thread the hit will occur.

Below is the updated source files for all the examples:

ImageWorker

I’ve also updated the respective articles with new Examples and Source Code.

Thanks!

Written by

3 Comments to “Intro to AS3 Workers (Part 4): Fixes for the Release Player”

  1. junlas says:

    学习了,非常的有帮助。 :)

  2. Peter says:

    AS3 Workers suck so much… cant use events, instead you use weird messages, byte array serialization, cant run functions from main class, everything is double, exception wont show, doesnt look like AS3 syntax. This isnt real threading like in C# dont know what it is…. Hope they get this sorted, and scratch that…Fingers crossed for AS4 lolo

  3. adampasz says:

    Having dug into this a bit, I’m afraid I agree with Peter. The implementation feels only slightly less hacky than having 2 SWFs on a page talking to each other via LocalConnection or ExternalInterface.

Leave a Reply

Message