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

推荐订阅源

D
DataBreaches.Net
S
Schneier on Security
T
The Exploit Database - CXSecurity.com
Webroot Blog
Webroot Blog
AI
AI
P
Palo Alto Networks Blog
Attack and Defense Labs
Attack and Defense Labs
WordPress大学
WordPress大学
月光博客
月光博客
阮一峰的网络日志
阮一峰的网络日志
Spread Privacy
Spread Privacy
T
Tor Project blog
罗磊的独立博客
小众软件
小众软件
S
Security Affairs
酷 壳 – CoolShell
酷 壳 – CoolShell
量子位
Apple Machine Learning Research
Apple Machine Learning Research
T
Threatpost
NISL@THU
NISL@THU
博客园_首页
PCI Perspectives
PCI Perspectives
大猫的无限游戏
大猫的无限游戏
IT之家
IT之家
N
News and Events Feed by Topic
freeCodeCamp Programming Tutorials: Python, JavaScript, Git & More
Forbes - Security
Forbes - Security
博客园 - 叶小钗
D
Darknet – Hacking Tools, Hacker News & Cyber Security
OSCHINA 社区最新新闻
OSCHINA 社区最新新闻
Last Week in AI
Last Week in AI
L
LINUX DO - 热门话题
T
Threat Research - Cisco Blogs
cs.AI updates on arXiv.org
cs.AI updates on arXiv.org
腾讯CDC
Security Latest
Security Latest
Exploit-DB.com RSS Feed
Exploit-DB.com RSS Feed
The Cloudflare Blog
A
About on SuperTechFans
爱范儿
爱范儿
Threat Intelligence Blog | Flashpoint
Threat Intelligence Blog | Flashpoint
TaoSecurity Blog
TaoSecurity Blog
宝玉的分享
宝玉的分享
G
GRAHAM CLULEY
雷峰网
雷峰网
F
Full Disclosure
I
Intezer
Cloudbric
Cloudbric
博客园 - 三生石上(FineUI控件)
U
Unit 42

MarcySutton.com RSS Feed

On Joining Khan Academy Developing anti-SLAPP policies for A11y Slack with Harvard Cyberlaw Clinic Focus on What Matters Celebrating One Year of Independence as Modern Sole Design, LLC Evinced is Pushing the Limits of Automated Accessibility Testing Content-visibility and Accessible Semantics Finding accessibility jobs in specialized companies and the mainstream Outsider Leverage and Accessibility Encouraging Open Source Contributions with Docs: a Self-Fulfilling Prophecy Remote Work and Van Life Salary and Career Growth Prototype Testing for Accessible Client-Side Routing On Great Leadership, Gatsby & Girl Develop It The Deal with Developer Advocacy Live Coding Accessibility Chapter Two at Deque 2017, in Music Writing winning abstracts Accessibility is a Civil Right 2016, a Year of Milestones Best of 2016 Music Links vs. Buttons in Modern Web Applications Accessibility and Performance I won an O Web Accessibility Resources This is what a developer looks like. What Wally On writing better captions for images What I’ve Learned Working on a Large Open-Source Framework Speak at your local elementary school. Button Focus Hell Page Scrolling in Mobile Safari & VoiceOver Accessibility Wins Notes from CSUN 2015 Protractor Accessibility Plugin Riding a bicycle to an accessibility conference 2014: One to Remember AngularJS Material Design & ngAria Summing Up JSConf EU 2014 How I Audit a Website for Accessibility Accessibility and the Shadow DOM: JSConf Australia 2014 CSUN 2014 Conference Recap Accessibility and the Shadow DOM Favorite Music 2013 Girl Develop It Web Accessibility Mobile Web Accessibility with VoiceOver Webstock & NZ 2013 Favorite Music 2012 Target Corporate Site Redesign: Accessible & Responsive Web Development Decibel Festival Recap 2012 Favorite Music 2011 Spiceboard: Wordpress Recipes for iPad POP Clock Favorite Music 2010 CSS + JS + Accessibility Christmas JS1k Zend Framework. NACCC Urban Type Sutton RV Simplexml in php 5 AS3 Load Workflow Holiday 2009 Why Outlook Sucks
AS3 Mouse Events
2010-01-05 · via MarcySutton.com RSS Feed

January 5, 2010

I developed a website with nav items that covered the whole stage from top to bottom and I ran into a problem where it was pretty easy for the mouse to exit the stage in the middle of a MOUSE_OVER event, not triggering the MouseEvent.MOUSE_OUT events required to “turn off” said nav items.

I wondered: should I be using Event.MOUSE_LEAVE to detect when the mouse has left the stage, and turn off any enabled nav items? That is what I tried to do, but I had trouble getting any output from the listener when I applied it to a MovieClip (this).

this.stage.addEventListener(Event.MOUSE_LEAVE, mouseLeaveListener);

I had the right event syntax, but it didn’t seem to do anything no matter what I tried. After testing, posting on StackOverflow and learning more about AS3, I found out a few things about MouseEvents:

  1. Make sure the target object has been added to the stage before applying Mouse event listeners to it.
  2. If the problem still persists, test your file in a browser. In my situation, the MOUSE_OUT issue only seemed to happen in the IDE.

Here is my MainNav.as class:

package com.redpropeller {
 
import com.greensock.*;
import com.greensock.plugins.*;
import flash.display.*;
import flash.text.*;
import flash.events.*;
 
public class MainNav extends MovieClip { // MainNav is a movieclip in the IDE
 
    public var colors:Array;
 
    public function MainNav():void {
        colors = new Array(0xee3124, 0xc72a1f, 0xa62c24, 0x912923, 0x7e221c);
        TweenPlugin.activate([TintPlugin]);
 
        this.addEventListener(Event.ADDED_TO_STAGE, navAddedListener);
    }
    private function navAddedListener(e:Event):void {
        // target the stage through this object after it has been added
        this.stage.addEventListener(Event.MOUSE_LEAVE, mouseLeaveListener);
 
        for(var i:Number=0; i<this.numChildren; i++){
            var n = this.getChildAt(i);
            n.useHandCursor = true;
            n.buttonMode = true;
 
            n.addEventListener(MouseEvent.MOUSE_OVER, navBtnOn);
            n.addEventListener(MouseEvent.MOUSE_OUT, navBtnOff);
        }
    }
    public function mouseLeaveListener(e:MouseEvent):void {
        trace('mouseleave'); // should fire after this has been added to stage
 
    }
    private function navBtnOn(e:MouseEvent):void {
        TweenLite.to(e.currentTarget.bar_mc, 0.01, {tint:0x333333});
    }
    private function navBtnOff(e:MouseEvent):void {
        TweenLite.to(e.currentTarget.bar_mc, 0.01,
            {tint:uint(colors[this.getChildIndex(MovieClip(e.currentTarget))])});
            // changes color back to specific tint
    }
}
 
}