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

推荐订阅源

GbyAI
GbyAI
Threat Intelligence Blog | Flashpoint
Threat Intelligence Blog | Flashpoint
Hugging Face - Blog
Hugging Face - Blog
IT之家
IT之家
Jina AI
Jina AI
Google DeepMind News
Google DeepMind News
大猫的无限游戏
大猫的无限游戏
The GitHub Blog
The GitHub Blog
腾讯CDC
L
LangChain Blog
P
Proofpoint News Feed
M
MIT News - Artificial intelligence
F
Fortinet All Blogs
量子位
Apple Machine Learning Research
Apple Machine Learning Research
Cloudbric
Cloudbric
B
Blog RSS Feed
B
Blog
C
CXSECURITY Database RSS Feed - CXSecurity.com
Vercel News
Vercel News
S
Schneier on Security
Project Zero
Project Zero
宝玉的分享
宝玉的分享
美团技术团队
MyScale Blog
MyScale Blog
OSCHINA 社区最新新闻
OSCHINA 社区最新新闻
Spread Privacy
Spread Privacy
T
Threatpost
A
Arctic Wolf
Exploit-DB.com RSS Feed
Exploit-DB.com RSS Feed
Hacker News - Newest:
Hacker News - Newest: "LLM"
爱范儿
爱范儿
Recorded Future
Recorded Future
C
CERT Recently Published Vulnerability Notes
T
Threat Research - Cisco Blogs
cs.CV updates on arXiv.org
cs.CV updates on arXiv.org
SecWiki News
SecWiki News
H
Hacker News: Front Page
AWS News Blog
AWS News Blog
博客园_首页
freeCodeCamp Programming Tutorials: Python, JavaScript, Git & More
T
Tor Project blog
C
Check Point Blog
L
Lohrmann on Cybersecurity
F
Full Disclosure
TaoSecurity Blog
TaoSecurity Blog
Google Online Security Blog
Google Online Security Blog
云风的 BLOG
云风的 BLOG
The Last Watchdog
The Last Watchdog
Martin Fowler
Martin Fowler

博客园 - 晓光

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 Module通信(2)——使用事件 (转)Flex Modules通信(1)——通过接口 (转)FLEX中使用outerDocument - 晓光 - 博客园 (转)C# Hashtable Synchronized vs SyncRoot
(转)Canvas不能接收 rollOver和roolOut事件的解决方案 - 晓光 - 博客园
晓光 · 2010-07-11 · via 博客园 - 晓光

<?xml version="1.0" encoding="utf-8"?>
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" layout="absolute">
       
    <mx:Canvas id="canvas" x="10" y="10" width="200" height="200"
        rollOver="trace('in')" rollOut="trace('out')" />
       
</mx:Application>


编译后,你把鼠标移上去,会发现没有任何输出,

解决方法:

 程序代码
1,<mx:Canvas id="canvas" x="10" y="10" width="200" height="200"
        rollOver="trace('in')" rollOut="trace('out')" backgroundAlpha="0" backgroundColor="#ff000"/>
 程序代码
2,<mx:Canvas id="canvas" x="10" y="10" width="200" height="200"
        rollOver="trace('in')" rollOut="trace('out')"
        preinitialize="canvas.setStyle('mouseShield', true);"/>


前提是你的 canvas 的 borderSkin 是 mx.skins.halo::HaloBorder.

原理:
没有任何内容的透明Canvas ,鼠标放上去,空无一物,当然不能触发鼠标事件。
所以我们要
1,backgroundAlpha="0" backgroundColor="#ff000"。
或者
2,将canvas的 mouseShield 样式设为 true,容器会自动给自己绘制一个alpha=0,白色的背景
backgroundAlpha="0" backgroundColor="#ffffff"(可以参考mx.skins.halo::HaloBorder类的drawBackground函数)

为什么MouseEvent.CLICK,MouseEvent.DOUBLE_CLICK,MouseEvent.MOUSE_DOWN,MouseEvent.MOUSE_MOVE,
MouseEvent.MOUSE_OVER,MouseEvent.MOUSE_OUT,MouseEvent.MOUSE_UP,
MouseEvent.MOUSE_WHEEL事件不需要这样做,因为当设置这些事件的时候,flex自动的给canvas设置了setStyle('mouseShield', true) 样式(可以参考mx.core::Container 类的addEventListener 函数)。