0 Replies Latest reply on Mar 13, 2013 5:47 AM by nigedd

    Workers in AIR for desktop


      My question here specific to AIR apps for desktop, not for the web. I have Flex 4.6 and AIR 3.5. I've beed Googling for days with no joy.


      There are no code errors but does anyone know where and how to initialize workers in the main mxml file or hat appliaction handler should be used to get the worker thread to set the mainToWorker and workerToMain MessageChannel's, as there is no class initializer like there is in web flex projects.



                                                        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);




           // if in worker thread

                                                        mainToWorker = Worker.current.getSharedProperty("mainToWorker");

                                                        workerToMain = Worker.current.getSharedProperty("workerToMain");

                                                        mainToWorker.addEventListener(Event.CHANNEL_MESSAGE, onMainToWorker);