Worker在getSharedProperty()中没有收到MessageChannel对象

时间:2016-11-04 19:45:51

标签: actionscript-3 air flash-cs6 worker

我正在使用AIR 23 SDK创建AIR应用程序,并且需要使用Worker对象。使用this adobe documentation我做了一个简单的例子来理解它。代码如下:

if(Worker.current.isPrimordial) {

    var worker:Worker = WorkerDomain.current.createWorker(this.loaderInfo.bytes);

    var mainToWorker:MessageChannel = Worker.current.createMessageChannel(worker);
    var workerToMain:MessageChannel = worker.createMessageChannel(Worker.current);

    worker.setSharedProperty("mtw", mainToWorker);
    worker.setSharedProperty("wtm", workerToMain);

    worker.start();

    trace("[MAIN] Start worker.");
    trace("[MAIN] Property one: "+worker.getSharedProperty("mtw"));
    trace("[MAIN] Property two: "+worker.getSharedProperty("wtm"));

}
else {

    trace("[WORKER] Status: "+Worker.current.state);

    var mtw = Worker.current.getSharedProperty("mtw");
    var wtm = Worker.current.getSharedProperty("wtm");

    trace("[WORKER] Property one: "+mtw);
    trace("[WORKER] Property two: "+wtm);

}

但输出痕迹是:

[MAIN] Start worker.
[MAIN] Property one: [object MessageChannel]
[MAIN] Property two: [object MessageChannel]
[WORKER] Status: running
[WORKER] Property one: undefined
[WORKER] Property two: undefined

当我将AIR SDK更改为3.4时,它可以正常工作!跟踪更改为:[WORKER] Property one: [object MessageChannel][WORKER] Property two: [object MessageChannel]

这是一个错误吗?有人能帮助我吗?

0 个答案:

没有答案