惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

人人都是产品经理
人人都是产品经理
Stack Overflow Blog
Stack Overflow Blog
L
LINUX DO - 最新话题
Google Online Security Blog
Google Online Security Blog
Schneier on Security
Schneier on Security
Spread Privacy
Spread Privacy
www.infosecurity-magazine.com
www.infosecurity-magazine.com
雷峰网
雷峰网
Google DeepMind News
Google DeepMind News
Microsoft Azure Blog
Microsoft Azure Blog
IT之家
IT之家
V
Vulnerabilities – Threatpost
K
Kaspersky official blog
S
Schneier on Security
B
Blog
The Register - Security
The Register - Security
SecWiki News
SecWiki News
Hacker News: Ask HN
Hacker News: Ask HN
cs.AI updates on arXiv.org
cs.AI updates on arXiv.org
S
Security Affairs
T
The Blog of Author Tim Ferriss
G
Google Developers Blog
T
Tenable Blog
P
Proofpoint News Feed
Apple Machine Learning Research
Apple Machine Learning Research
D
DataBreaches.Net
S
Secure Thoughts
Security Latest
Security Latest
H
Heimdal Security Blog
The Hacker News
The Hacker News
O
OpenAI News
AWS News Blog
AWS News Blog
量子位
Exploit-DB.com RSS Feed
Exploit-DB.com RSS Feed
腾讯CDC
U
Unit 42
L
Lohrmann on Cybersecurity
cs.CL updates on arXiv.org
cs.CL updates on arXiv.org
L
LangChain Blog
阮一峰的网络日志
阮一峰的网络日志
T
The Exploit Database - CXSecurity.com
NISL@THU
NISL@THU
cs.CV updates on arXiv.org
cs.CV updates on arXiv.org
Application and Cybersecurity Blog
Application and Cybersecurity Blog
Hugging Face - Blog
Hugging Face - Blog
The Last Watchdog
The Last Watchdog
Recorded Future
Recorded Future
V2EX - 技术
V2EX - 技术
爱范儿
爱范儿
F
Full Disclosure

博客园 - 晓光

Android获取手机短信 Android系统的进程,任务,服务的信息 Android程序如何安装到内存或卡中 (转)解决Debug certificate expired的问题 (转)Android ViewGroup的onInterceptTouchEvent()事件分析 (转)禁止横屏和竖屏切换 (转)Android Bitmap 与 Drawable之间的转换 (转)Android中两种设置全屏的方法 (转)Android之getSystemService (转)SQL Server Compact Edition 数据库连接字符串 (转)Android Project Structure (转)SqlDateTime溢出类错误解决 C# 数据库连接字符串集合 - 晓光 - 博客园 Android Activity生命周期 Flex HttpService,WebService简单介绍 (转)Flex Modules通信(1)——通过接口 (转)Canvas不能接收 rollOver和roolOut事件的解决方案 - 晓光 - 博客园 (转)FLEX中使用outerDocument - 晓光 - 博客园 (转)C# Hashtable Synchronized vs SyncRoot
(转)Flex Module通信(2)——使用事件
晓光 · 2010-08-20 · via 博客园 - 晓光

上一篇讨 论通过实现接口来实现Application和Modules的通信,本篇讨论通过使用事件实现Application和Modules的通信。在一个 swf中,组件间的交互通信可以直接使用addEventListener和dispatchEvent来完成事件的传递。当然这样的标准做法也适用于 Module。

      通过addEventListener和dispatchEvent在Module发布事件:

 1:  <?xml version="1.0" encoding="utf-8"?>
 2:  <mx:Module xmlns:mx="http://www.adobe.com/2006/mxml" creationComplete="onComplete()">
 3:   <mx:Script>
 4:   <![CDATA[
 5:              import mx.events.DynamicEvent;
 6:   
 7:              [Bindable]private var command:String="";
 8:              private function onComplete():void
 9:   {
                     //从Application订阅
10:                  var sharedEventDispatcher:IEventDispatcher=systemManager.loaderInfo.sharedEvents;
11:   
12:                  sharedEventDispatcher.addEventListener("init",onInit,false,0,true);
13:                  //通知Application:Module创建完成
14:                  sharedEventDispatcher.dispatchEvent(new Event(Event.COMPLETE));
15:              }
16:    
17:              private function onInit(event:DynamicEvent):void
18:   {
19:                  command=event.data as String;
20:              }
21:   
22:          ]]>
23:      </mx:Script>
24:   
25:   <mx:Panel id="panel" title="Module With Events. {command}" width="400"  height="200"/>
26:  </mx:Module>
27:   

        运行结果,LoadModule后显示从Application传入的内容:

image