<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Flex Examples &#187; mouseLeave</title>
	<atom:link href="http://blog.flexexamples.com/tag/mouseleave/feed/" rel="self" type="application/rss+xml" />
	<link>http://blog.flexexamples.com</link>
	<description>Just a bunch of Adobe Flex Examples</description>
	<lastBuildDate>Wed, 26 Jan 2011 18:09:51 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>Detecting when a mouse leaves a Flex application</title>
		<link>http://blog.flexexamples.com/2008/02/22/detecting-when-a-mouse-leaves-a-flex-application/</link>
		<comments>http://blog.flexexamples.com/2008/02/22/detecting-when-a-mouse-leaves-a-flex-application/#comments</comments>
		<pubDate>Sat, 23 Feb 2008 06:18:57 +0000</pubDate>
		<dc:creator>Peter deHaan</dc:creator>
				<category><![CDATA[ActionScript]]></category>
		<category><![CDATA[Application]]></category>
		<category><![CDATA[PopUpManager]]></category>
		<category><![CDATA[mouseLeave]]></category>
		<category><![CDATA[mouseMove]]></category>
		<category><![CDATA[removePopUp()]]></category>
		<category><![CDATA[stage]]></category>

		<guid isPermaLink="false">http://blog.flexexamples.com/2008/02/22/detecting-when-a-mouse-leaves-a-flex-application/</guid>
		<description><![CDATA[<p>The following example shows how you can detect when the mouse leaves the bounds of a Flex application by listening for the stage object&#8217;s mouseLeave event.</p> <p>Full code after the jump.</p> <p></p> <p class="download"><a href="http://blog.flexexamples.com/wp-content/uploads/Stage_mouseLeave_test/main.mxml">View MXML</a></p> &#60;?xml version="1.0" encoding="utf-8"?&#62; &#60;!-- http://blog.flexexamples.com/2008/02/22/detecting-when-a-mouse-leaves-a-flex-application/ --&#62; &#60;mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" layout="vertical" verticalAlign="top" backgroundColor="white" applicationComplete="init();"&#62; &#60;mx:Style&#62; Alert { modalTransparencyColor: black; modalTransparency: 0.6; [...]]]></description>
			<content:encoded><![CDATA[<p>The following example shows how you can detect when the mouse leaves the bounds of a Flex application by listening for the stage object&#8217;s <code>mouseLeave</code> event.</p>
<p>Full code after the jump.</p>
<p><span id="more-528"></span></p>
<p class="download"><a href="http://blog.flexexamples.com/wp-content/uploads/Stage_mouseLeave_test/main.mxml">View MXML</a></p>
<pre class="code">
&lt;?xml version="1.0" encoding="utf-8"?&gt;
&lt;!-- http://blog.flexexamples.com/2008/02/22/detecting-when-a-mouse-leaves-a-flex-application/ --&gt;
&lt;mx:Application xmlns:mx="http://www.adobe.com/2006/mxml"
        layout="vertical"
        verticalAlign="top"
        backgroundColor="white"
        applicationComplete="init();"&gt;

    &lt;mx:Style&gt;
        Alert {
            modalTransparencyColor: black;
            modalTransparency: 0.6;
        }
    &lt;/mx:Style&gt;

    &lt;mx:Script&gt;
        &lt;![CDATA[
            import mx.controls.Alert;
            import mx.managers.PopUpManager;

            private var _isMouseInSWF:Boolean = false;
            private var alert:Alert;

            [Bindable]
            private function get isMouseInSWF():Boolean {
                return _isMouseInSWF;
            }

            private function set isMouseInSWF(value:Boolean):void {
                _isMouseInSWF = value;
            }

            private function init():void {
                stage.addEventListener(MouseEvent.MOUSE_MOVE, stage_mouseMove);
                stage.addEventListener(Event.MOUSE_LEAVE, stage_mouseLeave);
            }

            private function stage_mouseLeave(evt:Event):void {
                isMouseInSWF = false;
                if (alert) {
                    PopUpManager.removePopUp(alert);
                }
                alert = Alert.show("GONE");
            }

            private function stage_mouseMove(evt:MouseEvent):void {
                if (!isMouseInSWF) {
                    if (alert) {
                        PopUpManager.removePopUp(alert);
                    }
                    // alert = Alert.show("BACK");
                    isMouseInSWF = true;
                }
            }
        ]]&gt;
    &lt;/mx:Script&gt;

    &lt;mx:Label text="isMouseInSWF: {isMouseInSWF}" /&gt;

&lt;/mx:Application&gt;
</pre>
<p class="information"><a href="http://blog.flexexamples.com/wp-content/uploads/Stage_mouseLeave_test/bin/srcview/index.html">View source</a> is enabled in the following example.</p>
<p><iframe src="http://blog.flexexamples.com/wp-content/uploads/Stage_mouseLeave_test/bin/main.html" width="100%" height="300"></iframe></p>
<div class="evernoteSiteMemory"><a href="javascript:" onclick="Evernote.doClip({title: 'Detecting when a mouse leaves a Flex application on FlexExamples.com',url: 'http://blog.flexexamples.com/2008/02/22/detecting-when-a-mouse-leaves-a-flex-application/',contentID: 'post-528',code: 'Pete9667',suggestNotebook: 'FlexExamples',suggestTags: 'mouseLeave,mouseMove,removePopUp(),stage',providerName: 'FlexExamples.com',styling: 'text' });return false" class="evernoteSiteMemoryLink"><img src="http://static.evernote.com/article-clipper-remember.png" class="evernoteSiteMemoryButton" />
				</a>				<div class="evernoteSiteMemoryClear">&nbsp;</div>
</div>]]></content:encoded>
			<wfw:commentRss>http://blog.flexexamples.com/2008/02/22/detecting-when-a-mouse-leaves-a-flex-application/feed/</wfw:commentRss>
		<slash:comments>14</slash:comments>
		</item>
	</channel>
</rss>

