Взял
пример работы worker. Создал проект в FD, но после запуска ответа от воркера не приходит.
Output такой:
[Starting debug session with FDB]
[Main] HELLO
[Main] HELLO
[Main] HELLO
А должен быть, как я понимаю, такой:
[Starting debug session with FDB]
[Main] HELLO
[Worker] WORLD
[Main] HELLO
[Worker] WORLD
[Main] HELLO
[Worker] WORLD
Вот код примера:

Код AS3:
protected var mainToWorker:MessageChannel;
protected var workerToMain:MessageChannel;
protected var worker:Worker;
public function Main2():void
{
/**
* Start Main thread
**/
if(Worker.current.isPrimordial){
worker = WorkerDomain.current.createWorker(this.loaderInfo.bytes);
mainToWorker = Worker.current.createMessageChannel(worker);
workerToMain = worker.createMessageChannel(Worker.current);
worker.setSharedProperty("mainToWorker", mainToWorker);
worker.setSharedProperty("workerToMain", workerToMain);
workerToMain.addEventListener(Event.CHANNEL_MESSAGE, onWorkerToMain);
worker.start();
//Set an interval that will ask the worker thread to do some math
setInterval(function():void{
mainToWorker.send("HELLO");
trace("[Main] HELLO");
}, 1000);
}
/**
* Start Worker thread
**/
else
{
//Inside of our worker, we can use static methods to
//access the shared messgaeChannel's
mainToWorker = Worker.current.getSharedProperty("mainToWorker");
workerToMain = Worker.current.getSharedProperty("workerToMain");
//Listen for messages from Main
mainToWorker.addEventListener(Event.CHANNEL_MESSAGE, onMainToWorker);
}
}
//Receive messages FROM the Main Thread
protected function onMainToWorker(event:Event):void {
var msg:* = mainToWorker.receive();
//When the main thread sends us HELLO, we'll send it back WORLD
if(msg == "HELLO"){
workerToMain.send("WORLD");
}
}
//Set an interval that will ask the worker thread to do some math
//Receive messages FROM the Worker
protected function onWorkerToMain(event:Event):void {
//Trace out whatever message the worker has sent us.
trace("[Worker] " + workerToMain.receive());
}
Не могу понять в чем проблема?