Worker not functionning in distribution or TestFlight build
I'm using an embedded SWF file to use as a worker in my app. On iOS devices, the communication with the worker is fine when I debug the app. Builds created for TestFlight (distribution build), won't function properly. I can trace the state of the worker as "running" but nothing is comming through the messageChannels.
// embed SWF
[Embed(source="../../workers/WorkerTest.swf", mimeType="application/octet-stream")]
private static var WORKER_SWF:Class;
protected var worker:Worker;
private var workerToMainStartupChannel:MessageChannel;
// Create the worker
var workerBytes:ByteArray = new SOUNDWAVE_SWF() as ByteArray;
worker = WorkerDomain.current.createWorker(workerBytes);
// set up channel
workerToMainStartupChannel = worker.createMessageChannel(Worker.current);
workerToMainStartupChannel.addEventListener(Event.CHANNEL_MESSAGE, onWorkerToMainStartup);
worker.setSharedProperty("workerToMainStartup", workerToMainStartupChannel);
worker.addEventListener(Event.WORKER_STATE,onWorkerState);
worker.start();
private function onWorkerState(e:Event):void
{
if (worker.state == WorkerState.RUNNING)
{
// this always gets traced
trace("WORKER RUNNING");
}
}
public function onWorkerToMainStartup(evt:Event):void
{
// this only gets traced on debug builds
var success:Boolean = workerToMainStartupChannel.receive() as Boolean;
if (!success)
{
trace("worker failure")
}
else
{
trace("worker stared");
}
}
}
// WORKER
public class WorkerTest extends Sprite
{
protected var workerToMainStartup:MessageChannel;
public function WorkerTest()
{
// Send startup message to main
workerToMainStartup = Worker.current.getSharedProperty("workerToMainStartup");
workerToMainStartup.send(true);
}
}
Note : the Worker SWF is published to a folder inside the the main app structure.
Any ideas?
Cheers
