Flash多线程学习资料导航
来源:互联网 发布:我的从医感受淘宝店 编辑:程序博客网 时间:2024/05/16 10:02
FP11.4的新功能竟然是多线程~~囧~~
- 多线程资讯
- 多线程入门教程系列
下面copy一篇代码以做学习之资~~
package{import flash.display.Sprite;import flash.events.Event;import flash.system.MessageChannel;import flash.system.Worker;import flash.system.WorkerDomain;import flash.utils.setInterval;public class HelloWorldWorker extends Sprite{protected var mainToWorker:MessageChannel;protected var workerToMain:MessageChannel;protected var worker:Worker;public function HelloWorldWorker(){/** * Start Main thread **/if(Worker.current.isPrimordial){//Create worker from our own loaderInfo.bytesworker = WorkerDomain.current.createWorker(this.loaderInfo.bytes);//Create messaging channels for 2-way messagingmainToWorker = Worker.current.createMessageChannel(worker);workerToMain = worker.createMessageChannel(Worker.current);//Inject messaging channels as a shared propertyworker.setSharedProperty("mainToWorker", mainToWorker);worker.setSharedProperty("workerToMain", workerToMain);//Listen to the response from our workerworkerToMain.addEventListener(Event.CHANNEL_MESSAGE, onWorkerToMain);//Start worker (re-run document class)worker.start();//Set an interval that will ask the worker thread to do some mathsetInterval(function(){mainToWorker.send("ADD");mainToWorker.send(2);mainToWorker.send(2);}, 1000);} /** * Start Worker thread **/else {//Inside of our worker, we can use static methods to //access the shared messgaeChannel'smainToWorker = Worker.current.getSharedProperty("mainToWorker");workerToMain = Worker.current.getSharedProperty("workerToMain");//Listen for messages from the mian threadmainToWorker.addEventListener(Event.CHANNEL_MESSAGE, onMainToWorker);}}//Main >> Workerprotected function onMainToWorker(event:Event):void {var msg:* = mainToWorker.receive();//When the main thread sends us HELLO, we'll send it back WORLDif(msg == "HELLO"){workerToMain.send("WORLD");}else if(msg == "ADD"){//Receive the 2 numbers and add them togethervar result:int = mainToWorker.receive() + mainToWorker.receive();//Return the result to the main threadworkerToMain.send(result);}}//Worker >> Mainprotected function onWorkerToMain(event:Event):void {//Trace out whatever message the worker has sent us.trace("[Worker] " + workerToMain.receive());}}}
- Flash多线程学习资料导航
- flash:flash学习资料
- 学习资料导航
- FLASH学习资料整理
- flash学习资料整理
- flash学习资料
- 多线程学习资料
- 多线程学习资料
- flash 3D 学习资料收集
- 多线程方面很好的学习资料
- Java 5.0多线程编程学习资料笔录
- cocos2d-x的多线程学习资料
- java多线程学习资料网站集合
- C# 多线程并发编程资料汇总学习
- Linux下的多线程编程 学习资料
- Node.js 中文学习资料和教程导航
- Flash Builder 4等Flex学习资料汇总
- 多线程资料
- 建立嵌入式gdb调试环境
- linux下C语言socket网络编程简例
- 数据结构之快速排序
- 对心脏极其不好的生活方式有哪些
- 驱动程序安装类(C#)
- Flash多线程学习资料导航
- Hashcode的作用
- UVa 350 - Pseudo-Random Numbers
- 摄影构图在网页设计中活学活用
- android 图片平铺与拉伸
- 浅谈.NET中的委托
- C# Web开发 标准读写Cookies的方法 支持跨二级域和虚拟目录
- PCB导线宽度与截流能力的规定
- 关于AS3中ApplicationDomain之浅见(一)