<?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; activate</title>
	<atom:link href="http://blog.flexexamples.com/tag/activate/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>Determining if a Flex application has focus using the activate and deactivate events</title>
		<link>http://blog.flexexamples.com/2008/02/29/determining-if-a-flex-application-has-focus-using-the-activate-and-deactivate-events/</link>
		<comments>http://blog.flexexamples.com/2008/02/29/determining-if-a-flex-application-has-focus-using-the-activate-and-deactivate-events/#comments</comments>
		<pubDate>Fri, 29 Feb 2008 15:11:15 +0000</pubDate>
		<dc:creator>Peter deHaan</dc:creator>
				<category><![CDATA[Application]]></category>
		<category><![CDATA[activate]]></category>
		<category><![CDATA[deactivate]]></category>

		<guid isPermaLink="false">http://blog.flexexamples.com/2008/02/29/determining-if-a-flex-application-has-focus-using-the-activate-and-deactivate-events/</guid>
		<description><![CDATA[<p>The following example shows how you can determine if a Flex application has focus or not by listening for the activate and deactivate events on the &#60;mx:Application /&#62; container.</p> <p>Full code after the jump.</p> <p></p> <p class="download"><a href="http://blog.flexexamples.com/wp-content/uploads/Application_activate_test/main.mxml" rel="shadowbox">View MXML</a></p> &#60;?xml version="1.0" encoding="utf-8"?&#62; &#60;!-- http://blog.flexexamples.com/2008/02/29/determining-if-a-flex-application-has-focus-using-the-activate-and-deactivate-events/ --&#62; &#60;mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" layout="vertical" verticalAlign="middle" backgroundColor="white" activate="application_activate(event);" deactivate="application_activate(event);"&#62; &#60;mx:Script&#62; &#60;![CDATA[ [...]]]></description>
			<content:encoded><![CDATA[<p>The following example shows how you can determine if a Flex application has focus or not by listening for the <code>activate</code> and <code>deactivate</code> events on the &lt;mx:Application /&gt; container.</p>
<p>Full code after the jump.</p>
<p><span id="more-535"></span></p>
<p class="download"><a href="http://blog.flexexamples.com/wp-content/uploads/Application_activate_test/main.mxml" rel="shadowbox">View MXML</a></p>
<pre class="code">
&lt;?xml version="1.0" encoding="utf-8"?&gt;
&lt;!-- http://blog.flexexamples.com/2008/02/29/determining-if-a-flex-application-has-focus-using-the-activate-and-deactivate-events/ --&gt;
&lt;mx:Application xmlns:mx="http://www.adobe.com/2006/mxml"
        layout="vertical"
        verticalAlign="middle"
        backgroundColor="white"
        activate="application_activate(event);"
        deactivate="application_activate(event);"&gt;

    &lt;mx:Script&gt;
        &lt;![CDATA[
            import mx.controls.dataGridClasses.DataGridColumn;

            private function application_activate(evt:Event):void {
                arrColl.addItemAt({type:evt.type, time:getTimer()}, 0);
            }

            private function time_labelFunc(item:Object, col:DataGridColumn):String {
                return numberFormatter.format(item[col.dataField]);
            }
        ]]&gt;
    &lt;/mx:Script&gt;

    &lt;mx:ArrayCollection id="arrColl" /&gt;

    &lt;mx:NumberFormatter id="numberFormatter"
            useThousandsSeparator="true" /&gt;

    &lt;mx:DataGrid id="dataGrid"
            dataProvider="{arrColl}"
            width="320"
            rowCount="8"
            verticalScrollPolicy="on"&gt;
        &lt;mx:columns&gt;
            &lt;mx:DataGridColumn dataField="type" /&gt;
            &lt;mx:DataGridColumn dataField="time"
                    headerText="time (ms)"
                    labelFunction="time_labelFunc" /&gt;
        &lt;/mx:columns&gt;
    &lt;/mx:DataGrid&gt;

&lt;/mx:Application&gt;
</pre>
<p class="information"><a href="http://blog.flexexamples.com/wp-content/uploads/Application_activate_test/bin/srcview/index.html" rel="shadowbox[album]">View source</a> is enabled in the following example.</p>
<p><iframe src="http://blog.flexexamples.com/wp-content/uploads/Application_activate_test/bin/main.html" width="100%" height="260"></iframe></p>
<p>To test the previous example, try clicking within the Flex application and then click on the surrounding HTML, you should see the &#8220;activate&#8221; and &#8220;deactivate&#8221; events get dispatched and create new items in the DataGrid control.</p>
<div class="evernoteSiteMemory"><a href="javascript:" onclick="Evernote.doClip({title: 'Determining if a Flex application has focus using the activate and deactivate events on FlexExamples.com',url: 'http://blog.flexexamples.com/2008/02/29/determining-if-a-flex-application-has-focus-using-the-activate-and-deactivate-events/',contentID: 'post-535',code: 'Pete9667',suggestNotebook: 'FlexExamples',suggestTags: 'activate,deactivate',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/29/determining-if-a-flex-application-has-focus-using-the-activate-and-deactivate-events/feed/</wfw:commentRss>
		<slash:comments>10</slash:comments>
		</item>
	</channel>
</rss>

