<?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>Query7 &#187; flex 3</title>
	<atom:link href="http://query7.com/tag/flex-3/feed" rel="self" type="application/rss+xml" />
	<link>http://query7.com</link>
	<description>PHP, Javascript, Python and Web Development</description>
	<lastBuildDate>Sat, 25 Jun 2011 21:29:51 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0.4</generator>
		<item>
		<title>Playing with MouseEvent in Flex 3</title>
		<link>http://query7.com/playing-with-mouseevent-in-flex-3</link>
		<comments>http://query7.com/playing-with-mouseevent-in-flex-3#comments</comments>
		<pubDate>Wed, 12 Nov 2008 04:58:12 +0000</pubDate>
		<dc:creator>Amar Shukla</dc:creator>
				<category><![CDATA[ActionScript]]></category>
		<category><![CDATA[Flash]]></category>
		<category><![CDATA[Flex]]></category>
		<category><![CDATA[AS3 MouseEvent]]></category>
		<category><![CDATA[flex 3]]></category>
		<category><![CDATA[flex 3 tricks]]></category>
		<category><![CDATA[Flex 3 Tutorial]]></category>
		<category><![CDATA[MouseEvent]]></category>
		<category><![CDATA[Playing with Events]]></category>

		<guid isPermaLink="false">http://www.webdevelopmentbits.com/?p=281</guid>
		<description><![CDATA[<p>I have come across a very interesting problem while developing a flex application where I have a<br />
button control and I want to call two different functions on  click of the button . The interesting part<br />
is that I want to call two different functions on different events of the same button control, one at<br />
single click and other at double click .<br />
Now what to do in this case as it will always execute the function defined at single click .<br />
So what I am gonna do is to use a Timer using setInterval( ) method and use it to solve this problem.</p>
<p>The code goes here -</p>
<p><code>&#60;?xml version="1.0" encoding="utf-8"?&#62;<br />
&#60;mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" layout="absolute"&#62;<br />
&#60;mx:Script&#62;<br />
&#60;![CDATA[<br />
import mx.controls.Alert;<br />
import flash.utils.clearInterval;<br />
private var timeGap:Number = new Number();<br />
private function doubleClick(event:MouseEvent):void {<br />
clearInterval(timeGap);<br />
//put your code here to be executed on double click<br />
Alert.show("double click");<br />
}<br />
private function singleClick(event:MouseEvent):void {<br />
clearInterval(timeGap);<br />
timeGap = setInterval(otherClick, 250);<br />
}<br />
private function otherClick():void {<br />
//put your code here to be executed on single click<br />
Alert.show("first click");<br />
clearInterval(timeGap);<br />
}<br />
]]&#62;<br</code>&#8230;</p>]]></description>
			<content:encoded><![CDATA[<p>I have come across a very interesting problem while developing a flex application where I have a<br />
button control and I want to call two different functions on  click of the button . The interesting part<br />
is that I want to call two different functions on different events of the same button control, one at<br />
single click and other at double click .<br />
Now what to do in this case as it will always execute the function defined at single click .<br />
So what I am gonna do is to use a Timer using setInterval( ) method and use it to solve this problem.</p>
<p>The code goes here -</p>
<p><code>&lt;?xml version="1.0" encoding="utf-8"?&gt;<br />
&lt;mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" layout="absolute"&gt;<br />
&lt;mx:Script&gt;<br />
&lt;![CDATA[<br />
import mx.controls.Alert;<br />
import flash.utils.clearInterval;<br />
private var timeGap:Number = new Number();<br />
private function doubleClick(event:MouseEvent):void {<br />
clearInterval(timeGap);<br />
//put your code here to be executed on double click<br />
Alert.show("double click");<br />
}<br />
private function singleClick(event:MouseEvent):void {<br />
clearInterval(timeGap);<br />
timeGap = setInterval(otherClick, 250);<br />
}<br />
private function otherClick():void {<br />
//put your code here to be executed on single click<br />
Alert.show("first click");<br />
clearInterval(timeGap);<br />
}<br />
]]&gt;<br />
&lt;/mx:Script&gt;<br />
&lt;mx:Button label="click" x="134" y="94"<br />
click="singleClick(event)"<br />
doubleClickEnabled="true"<br />
doubleClick="doubleClick(event)"/&gt;<br />
&lt;/mx:Application&gt;<br />
</code><br />
Now it&#8217;s the time to explain whats going on inside the code.<br />
On single click and double click events I am invoking two different Alerts to just display a message,<br />
In your case you can  write any code which is to be executed on those click events.</p>
<p>On click, inside the singleClick( ) method, we will reset &amp; initiate the timer which will call the<br />
otherClick( ) method on complete. otherClick( ) method contains actual single Click code.</p>
<p>If doubleClick is not invoked, then the  timer completes and otherClick( ) method is executed.<br />
But if doubleClick is invoked , it will call the doubleClick( ) method, where we will clear the<br />
timer  so the timer will not complete and execute the otherClick( ) method  and thus it will invoke the<br />
doubleClick( ) method.</p>
]]></content:encoded>
			<wfw:commentRss>http://query7.com/playing-with-mouseevent-in-flex-3/feed</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
	</channel>
</rss>

