Programación multitarea en Flash versión simple;

//Flash soporta multitarea solo apartir de la versión 11.4 import flash.events.Event; import flash.net.registerClassAlias; import flash.system.MessageChannel; import flash.system.Worker; import flash.system.WorkerDomain; import flash.system.WorkerState; import flash.utils.ByteArray; var workerToMain:MessageChannel; if (flash.system.Worker.current.isPrimordial) { var swfBytes:ByteArray = this.loaderInfo.bytes; var bgWorker:flash.system.Worker = flash.system.WorkerDomain.current.createWorker(swfBytes); // Receive from worker workerToMain = bgWorker.createMessageChannel(Worker.current); workerToMain.addEventListener(Event.CHANNEL_MESSAGE, onWorkerToMain); bgWorker.setSharedProperty("workerToMain", workerToMain); function onWorkerToMain(ev:Event): void { texto.text = workerToMain.receive(true) ; } bgWorker.start(); } else { workerToMain = Worker.current.getSharedProperty("workerToMain"); workerToMain.send("casdcascsd"); }

Be the first to comment

You can use [html][/html], [css][/css], [php][/php] and more to embed the code. Urls are automatically hyperlinked. Line breaks and paragraphs are automatically generated.