3

当我与工人共享 a 时,它似乎ByteArray.clear()没有做任何事情。ByteArray以这段代码为例:

package 
{
    import flash.display.Sprite;
    import flash.system.Worker;
    import flash.system.WorkerDomain;
    import flash.utils.ByteArray;

    public class Main extends Sprite 
    {
        private var _worker:Worker;

        public function Main():void 
        {
            if (Worker.current.isPrimordial)
            {
                initMain();
            }
            else
            {
                initWorker();
            }
        }

        private function initMain():void 
        {
            _worker = WorkerDomain.current.createWorker(loaderInfo.bytes, true);

            var bytes:ByteArray = new ByteArray();
            bytes.writeUnsignedInt(12836439);
            bytes.shareable = true;
            _worker.setSharedProperty("bytes", bytes);
            bytes.clear();
            trace(bytes.length);
        }

        private function initWorker():void
        {
            //worker stuff would go here
        }

    }

}

这痕迹4,虽然是应该的0。如果我注释掉bytes.shareable = true;or _worker.setSharedProperty("bytes", bytes);,它会完美运行,但组合似乎会以某种方式禁用该clear()方法。

然而,奇怪的是,这只发生在为 AIR 编译时。为 Flash Player 编译时,清除工作正常,并且此代码跟踪0.

有谁知道怎么回事?

4

0 回答 0