Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
  • 한국 커뮤니티
0

Worker/MessageChannel testing/debugging in Flash CC IDE

Community Beginner ,
Nov 27, 2018 Nov 27, 2018

Hello,

when I'm trying to Test or Debug AIR app in Flash IDE that needs to communicate with Worker through MessageChannel, I don't receive any messages from Worker.

Can you tell me if I'm missing something or there's no way for MessageChannel to work without Publishing the app?

Here's the code that's in MainApp and Worker.

MainApp:

import flash.filesystem.File;

import flash.filesystem.FileStream;

import flash.utils.ByteArray;

import flash.system.Worker;

import flash.system.WorkerDomain;

import flash.system.MessageChannel;

import flash.events.Event;

var workerFile:File = File.applicationDirectory.resolvePath("TFR2.swf");

var fs:FileStream = new FileStream();

fs.open(workerFile, "read");

var workerBA:ByteArray = new ByteArray();

fs.readBytes(workerBA);

fs.close();

var worker:Worker = WorkerDomain.current.createWorker(workerBA, true);

var mainToWorker:MessageChannel;

var workerToMain:MessageChannel;

var workerToMainStartup:MessageChannel;

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

worker.setSharedProperty("mainToWorker", mainToWorker);

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

workerToMain.addEventListener(Event.CHANNEL_MESSAGE, onWorkerToMain);

worker.setSharedProperty("workerToMain", workerToMain);

worker.start();

function onWorkerToMain(event:Event):void{

     trace(workerToMainStartup.receive());

}

Worker:

import flash.system.Worker;

import flash.system.MessageChannel;

if(!Worker.current.isPrimordial){

     var mainToWorker:MessageChannel = Worker.current.getSharedProperty("mainToWorker");

     mainToWorker.addEventListener(Event.CHANNEL_MESSAGE, onMainToWorker);

     var workerToMain:MessageChannel = Worker.current.getSharedProperty("workerToMain");

     workerToMainStartup.send("I'm ready to work!");

}

function onMainToWorker(event:Event):void{

     //process received data and return result

}

Thanks in advance.

TOPICS
ActionScript
367
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Engaged ,
Nov 29, 2018 Nov 29, 2018
LATEST

I have the same problem.

Here the bug for that: Tracker

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines