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

推荐订阅源

博客园 - 三生石上(FineUI控件)
Hugging Face - Blog
Hugging Face - Blog
M
MIT News - Artificial intelligence
T
Tailwind CSS Blog
Webroot Blog
Webroot Blog
S
Secure Thoughts
N
News and Events Feed by Topic
月光博客
月光博客
TaoSecurity Blog
TaoSecurity Blog
Microsoft Azure Blog
Microsoft Azure Blog
B
Blog RSS Feed
N
News | PayPal Newsroom
Exploit-DB.com RSS Feed
Exploit-DB.com RSS Feed
小众软件
小众软件
Recent Commits to openclaw:main
Recent Commits to openclaw:main
P
Privacy & Cybersecurity Law Blog
GbyAI
GbyAI
K
Kaspersky official blog
WordPress大学
WordPress大学
P
Proofpoint News Feed
cs.CV updates on arXiv.org
cs.CV updates on arXiv.org
博客园 - 叶小钗
W
WeLiveSecurity
Jina AI
Jina AI
The Cloudflare Blog
Project Zero
Project Zero
Simon Willison's Weblog
Simon Willison's Weblog
V
Vulnerabilities – Threatpost
L
LangChain Blog
Forbes - Security
Forbes - Security
PCI Perspectives
PCI Perspectives
Engineering at Meta
Engineering at Meta
Google DeepMind News
Google DeepMind News
Recorded Future
Recorded Future
博客园 - 【当耐特】
H
Heimdal Security Blog
A
About on SuperTechFans
Cisco Talos Blog
Cisco Talos Blog
T
Threat Research - Cisco Blogs
云风的 BLOG
云风的 BLOG
Spread Privacy
Spread Privacy
L
LINUX DO - 最新话题
L
Lohrmann on Cybersecurity
Last Week in AI
Last Week in AI
Google DeepMind News
Google DeepMind News
CTFtime.org: upcoming CTF events
CTFtime.org: upcoming CTF events
I
Intezer
Martin Fowler
Martin Fowler
S
Securelist
Threat Intelligence Blog | Flashpoint
Threat Intelligence Blog | Flashpoint

博客园 - 晓光

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