Skip to main content
markc888
Inspiring
July 23, 2015
Question

Trouble creating a background worker

  • July 23, 2015
  • 0 replies
  • 258 views

Hi,

I'm trying to set up a simple example of workers following the Adobe examples but when I try to create an instance of a worker it always returns null.

private var worker:Worker;

var workerLoader:URLLoader = new URLLoader();

workerLoader.dataFormat = URLLoaderDataFormat.BINARY;

workerLoader.addEventListener(Event.COMPLETE, loadComplete);

workerLoader.load(new URLRequest("BackWorker.swf"));

private function loadComplete(event:Event):void  {

var workerBytes:ByteArray = event.target.data as ByteArray;

trace(workerBytes.length); //this traces out 154876 so I know my worker swf is being loaded.

worker = WorkerDomain.current.createWorker(workerBytes);

trace(worker); //this traces null

  }

Would anyone have any ideas why the worker isn't being instantiated?

Thanks,

Mark

This topic has been closed for replies.