<?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>kasperkamperman.com : creative media technology &#187; Flash  &#8211; kasperkamperman.com : creative media technology</title>
	<atom:link href="http://www.kasperkamperman.com/blog/flash-code/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.kasperkamperman.com</link>
	<description>Kasper Kamperman designs and creates interactive and responsive media applications for exhibitions, interior and events. He works as a teacher in the field of Art and Technology</description>
	<lastBuildDate>Mon, 16 Jan 2012 14:52:40 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
		<item>
		<title>Flash as3: Framedifferencing collission detection (hitTest)</title>
		<link>http://www.kasperkamperman.com/blog/flash-as3-framedifferencing-collission-detection-hittest/</link>
		<comments>http://www.kasperkamperman.com/blog/flash-as3-framedifferencing-collission-detection-hittest/#comments</comments>
		<pubDate>Sun, 29 May 2011 14:52:13 +0000</pubDate>
		<dc:creator>kasperkamperman</dc:creator>
				<category><![CDATA[Blog]]></category>
		<category><![CDATA[Computer Vision]]></category>
		<category><![CDATA[Flash]]></category>

		<guid isPermaLink="false">http://www.kasperkamperman.com/?p=1134</guid>
		<description><![CDATA[Combination of Frame Differencing and hitTest in as3. Inspired by the Processing sketch of Andy Best where you can pop bubbles if there is movement. By checking the difference between two frames (current and the previous one) we know where there was movement. The movement is stored in a bitmap and with that we can [...]]]></description>
			<content:encoded><![CDATA[<p>Combination of Frame Differencing and hitTest in as3. Inspired by the<a href="http://andybest.net/2009/02/processing-opencv-tutorial-2-bubbles/"> Processing sketch of Andy Best</a> where you can pop bubbles if there is movement. By checking the difference between two frames (current and the previous one) we know where there was movement. The movement is stored in a bitmap and with that we can do a collission detection with other bitmap objects in the screen. </p>
<p>In the example below you&#8217;ll see two balls that change colour and position when hit. Code is in the zip-file.</p>
<p>See my post about <a href="http://www.kasperkamperman.com/blog/computer-vision/computervision-framedifferencing/">Frame differencing</a> for other Flash and Processing examples. </p>
<h2>Example (Flash Player 10 or higher)</h2>
<p>You need a webcam and give Flashplayer access to the camera to see the example below :</p>

<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000"
			id="fm_framedifferencing-hittest_1091437712"
			class="flashmovie"
			width="554"
			height="416">
	<param name="movie" value="http://www.kasperkamperman.com/wordpress_kk/wordpress_uploads/2011/05/framedifferencing-hittest.swf" />
	<!--[if !IE]>-->
	<object	type="application/x-shockwave-flash"
			data="http://www.kasperkamperman.com/wordpress_kk/wordpress_uploads/2011/05/framedifferencing-hittest.swf"
			name="fm_framedifferencing-hittest_1091437712"
			width="554"
			height="416">
	<!--<![endif]-->
		
<p><a href="http://adobe.com/go/getflashplayer"><img src="http://www.adobe.com/images/shared/download_buttons/get_flash_player.gif" alt="Get Adobe Flash player" /></a></p>

	<!--[if !IE]>-->
	</object>
	<!--<![endif]-->
</object>
<h2>Used resources</h2>
<ul>
<li><a href="http://www.mikechambers.com/blog/2009/06/24/using-bitmapdata-hittest-for-collision-detection/">Using BitmapData.hitTest for Collision Detection by Mike Chambers</a></li>
<li><a href="http://actionsnippet.com/?p=2820">code snippet from Zevan</a></li>
</ul>
<p><a class="download" href='http://www.kasperkamperman.com/wordpress_kk/wordpress_uploads/2011/05/framedifferencing-hittest.zip'>Download : Framedifferencing collision detection &#8211; source code</a></p>
<p>If you have suggestions for more improvements, please give your feedback in the comments. </p>
]]></content:encoded>
			<wfw:commentRss>http://www.kasperkamperman.com/blog/flash-as3-framedifferencing-collission-detection-hittest/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Flash QRcode reader as3</title>
		<link>http://www.kasperkamperman.com/blog/flash-qrcode-reader-as3/</link>
		<comments>http://www.kasperkamperman.com/blog/flash-qrcode-reader-as3/#comments</comments>
		<pubDate>Sun, 07 Nov 2010 13:26:57 +0000</pubDate>
		<dc:creator>kasperkamperman</dc:creator>
				<category><![CDATA[Blog]]></category>
		<category><![CDATA[Computer Vision]]></category>
		<category><![CDATA[Flash]]></category>

		<guid isPermaLink="false">http://www.kasperkamperman.com/?p=1057</guid>
		<description><![CDATA[QRreader example that uses the QR Code Reader by Logosware (libspark project). Code is improved with Adaptive Threshold (by Quasimondo) and other small modifications to improve the QRcode detection.  ]]></description>
			<content:encoded><![CDATA[<p>QRcode reader implementation that uses the QRCode Reader by Logosware (Libspark project). Code is improved with Adaptive Threshold (by Quasimondo) and other small modifications to improve the QRcode detection.  </p>
<h2>Modifications</h2>
<ul>
<li>Implemented Adaptive Threshold by Quasimondo (Mario Klingemann) in the GetQRimage Class.</li>
<li>Added the substract blur method that Mario Klingemann explains in his lecture about the
	process of reading QR codes. I&#8217;ve got less wrong strings in this mode and the detection runs faster.
	You can set it to false, to use the original method. </li>
<li>The outside parts of the video are cropped, to reduce image noise. By providing a markerGuide
	the user knows where to hold the marker.</li>
<li>The data from the onQrDecodeComplete event is compared with the data from a previous event as
	a way of extra error correction. </li>
</ul>
<p>The user interface uses the <a href="http://www.minimalcomps.com/">minimalcomps</a> by Keith Peters (bit-101) and the <a href="http://mrdoob.com/blog/post/582">Hi-Res! stats</a> by Mr. Doob. </p>
<h2>Example (Flash Player 10 or higher)</h2>
<p><a href=" http://qrcode.kaywa.com/">Generate a QRcode</a> and print it out.<br/>
You need a webcam and give Flashplayer access to the camera to see the example below :</p>

<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000"
			id="fm_ReadQrSimple_380278930"
			class="flashmovie"
			width="554"
			height="416">
	<param name="movie" value="http://www.kasperkamperman.com/wordpress_kk/wordpress_uploads/2010/11/ReadQrSimple.swf" />
	<!--[if !IE]>-->
	<object	type="application/x-shockwave-flash"
			data="http://www.kasperkamperman.com/wordpress_kk/wordpress_uploads/2010/11/ReadQrSimple.swf"
			name="fm_ReadQrSimple_380278930"
			width="554"
			height="416">
	<!--<![endif]-->
		
<p><a href="http://adobe.com/go/getflashplayer"><img src="http://www.adobe.com/images/shared/download_buttons/get_flash_player.gif" alt="Get Adobe Flash player" /></a></p>

	<!--[if !IE]>-->
	</object>
	<!--<![endif]-->
</object>
<h2>Used resources</h2>
<ul>
<li><a href="http://blog.jactionscripters.com/2009/05/23/introduction-of-qr-code-reader-library/">Introduction of QR Code Reader Library</a></li>
<li><a href="http://www.libspark.org/wiki/QRCodeReader/en">QRCodeReader library (Libspark)</a></li>
<li><a href="http://tv.adobe.com/watch/max-2008-develop/here-be-pixels-by-mario-klingemann">Max 2008 develop &#8211; Be here pixels by Mario Klingemann (interesting lecture)</a></li>
<li><a href="http://www.quasimondo.com/archives/000690.php">
Automated Threshold &#038; Edge Detection</a></li>
</ul>
<p><a class="download" href='http://www.kasperkamperman.com/wordpress_kk/wordpress_uploads/2010/11/ReadQrSimple-src.zip'>Download : ReadQrSimple &#8211; source code</a></p>
<p>If you have suggestions for more improvements, please give your feedback in the comments. </p>
]]></content:encoded>
			<wfw:commentRss>http://www.kasperkamperman.com/blog/flash-qrcode-reader-as3/feed/</wfw:commentRss>
		<slash:comments>6</slash:comments>
		</item>
		<item>
		<title>Arduino Flash communication AS3 &#8211; Messenger</title>
		<link>http://www.kasperkamperman.com/blog/arduino-flash-communication-as3-messenger/</link>
		<comments>http://www.kasperkamperman.com/blog/arduino-flash-communication-as3-messenger/#comments</comments>
		<pubDate>Thu, 13 May 2010 21:52:41 +0000</pubDate>
		<dc:creator>kasperkamperman</dc:creator>
				<category><![CDATA[Arduino]]></category>
		<category><![CDATA[Blog]]></category>
		<category><![CDATA[Flash]]></category>

		<guid isPermaLink="false">http://www.kasperkamperman.com/?p=857</guid>
		<description><![CDATA[Example how to setup serial communication between Flash and Arduino in combination with the Messenger library for Arduino. This is usefull if you want to use Arduino in a different way than as a sensorbox (if you want that check out the As3glue Firmata combination in my other post).]]></description>
			<content:encoded><![CDATA[<p>Example how to setup serial communication between Flash and Arduino in combination with the Messenger library for Arduino. You can send whatever you want between Arduino and Flash (if you only want to receive data from inputs and set outputs it better to use <a href="http://www.kasperkamperman.com/blog/arduino/arduino-flash-communication-as3/">Firmata / As3Glue combination</a>). </p>
<p>For receiving of data on the Arduino I&#8217;ll choose the <a href="http://www.arduino.cc/playground/Code/Messenger">Messenger library</a>. It has some nice simple functions and gives you the opportunity to check if a string is fully received (a &#8216;carriage return&#8217; is send by Flash at the end of a serial message in the SerialPort class) by Arduino. Of course you can write your own serial protocol. You can find some thoughts about it at the Todbot blog : <a href="http://todbot.com/blog/2009/07/30/arduino-serial-protocol-design-patterns/">Arduino serial protocol design patterns</a>.</p>
<p>You can send data to the serial port with the <a href="http://arduino.cc/en/Serial/Print">Serial.print()</a> and <a href="http://arduino.cc/en/Serial/Println">Serial.println()</a> commands.</p>
<p>Included is the SerialPort class for Flash that makes it easy to send and receive serial data from/to the Arduino. I&#8217;ve modified the original (from tinker.it) so it supports start and stop characters. As a stop character &#8216;carriage return&#8217; is used (&#8216;\r&#8217;, or char(13)) that is send when you do Serial.println(); from Arduino. </p>
<p>I advise using a start character (not used in the example below) as well, because sometimes (especially when sending on a high datarate) characters at the beginning if the string can get lost. </p>
<p>The download contains SerialPort.as and example_messenger.fla (CS3).  </p>
<p>Download : <a class="download" href='http://www.kasperkamperman.com/wordpress_kk/wordpress_uploads/2010/05/flash-arduino-as3-messenger.zip'>flash-arduino-as3-messenger</a></p>
<h2>Step by step guide for Messenger library communication</h2>
<ul>
<li>Download the <a href="http://www.arduino.cc/playground/Code/Messenger">Messenger library</a> and install it in your <em>Arduino/libraries/</em> folder ( you can find it by default in your documents folder ). Restart Arduino if it was running. </li>
<li>
Open basic_communication_old in my zip-file (basic_communication included in the Messenger examples has been changed).<br/><i>I&#8217;ve modified the old example in two ways. I&#8217;ve changed the serial speed to a baudrate of 57600, so you don&#8217;t have to change the Serproxy.cfg if you use it with Firmata as well and I have change the update interval to 40ms (instead of 20ms) for more stability.</i></li>
<li>Upload the Sketch to the Arduino.</li>
<li>Configure Serialproxy for your Arduino board and run it.</li>
<li>Open example_messenger.fla and run it.</li>
<li>If everything went fine you&#8217;ll see the led on pin 13 blinking and 6 balls, controlled by the analog inputs, moving on the screen.</li>
</ul>
<h2>Example_messenger code</h2>
<pre>
<div class="codecolorer-container actionscript3 default" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;height:450px;"><table cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:5px;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;font: normal 12px/1.4em Monaco, Lucida Console, monospace;"><div>1<br />2<br />3<br />4<br />5<br />6<br />7<br />8<br />9<br />10<br />11<br />12<br />13<br />14<br />15<br />16<br />17<br />18<br />19<br />20<br />21<br />22<br />23<br />24<br />25<br />26<br />27<br />28<br />29<br />30<br />31<br />32<br />33<br />34<br />35<br />36<br />37<br />38<br />39<br />40<br />41<br />42<br />43<br />44<br />45<br />46<br />47<br />48<br />49<br />50<br />51<br />52<br />53<br />54<br />55<br />56<br />57<br />58<br />59<br />60<br />61<br />62<br />63<br />64<br />65<br />66<br />67<br />68<br />69<br />70<br />71<br />72<br />73<br />74<br />75<br />76<br />77<br />78<br />79<br />80<br />81<br />82<br /></div></td><td><div class="actionscript3 codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color: #6699cc; font-weight: bold;">var</span> receivedValues<span style="color: #000066; font-weight: bold;">:</span><span style="color: #004993;">Array</span> = <span style="color: #0033ff; font-weight: bold;">new</span> <span style="color: #004993;">Array</span><span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span><br />
<br />
<span style="color: #009900; font-style: italic;">// Arduino connection</span><br />
<br />
<span style="color: #3f5fbf;">/* SerialPort(localhost, netport, start character, stop character)<br />
&nbsp; &nbsp;for more stability use a startcharacter so you can check if a message is complete<br />
&nbsp; &nbsp;default stop character is carriage return '\r' <br />
&nbsp; &nbsp;A carriage return is send by the Arduino command Serial.println();<br />
*/</span><br />
<br />
<span style="color: #6699cc; font-weight: bold;">var</span> arduino<span style="color: #000066; font-weight: bold;">:</span>SerialPort = <span style="color: #0033ff; font-weight: bold;">new</span> SerialPort<span style="color: #000000;">&#40;</span><span style="color: #990000;">&quot;127.0.0.1&quot;</span><span style="color: #000066; font-weight: bold;">,</span> <span style="color: #000000; font-weight:bold;">5331</span><span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span><br />
arduino<span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">addEventListener</span><span style="color: #000000;">&#40;</span><span style="color: #004993;">DataEvent</span><span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">DATA</span><span style="color: #000066; font-weight: bold;">,</span> onArduinoData <span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span><br />
arduino<span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">connect</span><span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span><br />
<br />
<span style="color: #009900; font-style: italic;">// Setup a timer to send data to the Arduino</span><br />
<span style="color: #009900; font-style: italic;">// The timer object calls the timerEvent function 20 times a second (every 50ms)</span><br />
<span style="color: #6699cc; font-weight: bold;">var</span> <span style="color: #004993;">timer</span> = <span style="color: #0033ff; font-weight: bold;">new</span> <span style="color: #004993;">Timer</span><span style="color: #000000;">&#40;</span><span style="color: #000000; font-weight:bold;">500</span><span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span><br />
<span style="color: #004993;">timer</span><span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">addEventListener</span><span style="color: #000000;">&#40;</span><span style="color: #990000;">&quot;timer&quot;</span><span style="color: #000066; font-weight: bold;">,</span> timerEvent<span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span><br />
<span style="color: #004993;">timer</span><span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">start</span><span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span><br />
<br />
<span style="color: #009900; font-style: italic;">// toggle variable that is switched by the timer from true to false and back</span><br />
<span style="color: #6699cc; font-weight: bold;">var</span> toggle<span style="color: #000066; font-weight: bold;">:</span><span style="color: #004993;">Boolean</span>= <span style="color: #0033ff; font-weight: bold;">true</span><span style="color: #000066; font-weight: bold;">;</span><br />
<br />
<span style="color: #339966; font-weight: bold;">function</span> timerEvent<span style="color: #000000;">&#40;</span>event<span style="color: #000066; font-weight: bold;">:</span><span style="color: #004993;">Event</span><span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">:</span><span style="color: #0033ff; font-weight: bold;">void</span> <br />
<span style="color: #000000;">&#123;</span> &nbsp; <br />
&nbsp; &nbsp; <span style="color: #009900; font-style: italic;">// change toggle boolean to the opposite</span><br />
&nbsp; &nbsp; toggle = <span style="color: #000066; font-weight: bold;">!</span>toggle<span style="color: #000066; font-weight: bold;">;</span><br />
&nbsp; &nbsp; <br />
&nbsp; &nbsp; <span style="color: #0033ff; font-weight: bold;">if</span><span style="color: #000000;">&#40;</span>toggle == <span style="color: #0033ff; font-weight: bold;">true</span><span style="color: #000000;">&#41;</span><br />
&nbsp; &nbsp; <span style="color: #000000;">&#123;</span> <span style="color: #009900; font-style: italic;">// make ledPin 13 HIGH - onboard led on </span><br />
&nbsp; &nbsp; &nbsp; <span style="color: #009900; font-style: italic;">//arduino.send(&quot;on&quot;); // For Messenger checkString example</span><br />
&nbsp; &nbsp; &nbsp; arduino<span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">send</span><span style="color: #000000;">&#40;</span><span style="color: #990000;">&quot;13 1&quot;</span><span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span> <span style="color: #009900; font-style: italic;">// For Messenger basic_communication example</span><br />
&nbsp; &nbsp; <span style="color: #000000;">&#125;</span><br />
&nbsp; &nbsp; <span style="color: #0033ff; font-weight: bold;">else</span><br />
&nbsp; &nbsp; <span style="color: #000000;">&#123;</span> <span style="color: #009900; font-style: italic;">// make ledPin 13 LOW - onboard led off</span><br />
&nbsp; &nbsp; &nbsp; <span style="color: #009900; font-style: italic;">//arduino.send(&quot;off&quot;); // For Messenger checkString example</span><br />
&nbsp; &nbsp; &nbsp; arduino<span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">send</span><span style="color: #000000;">&#40;</span><span style="color: #990000;">&quot;13 0&quot;</span><span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span> &nbsp;<span style="color: #009900; font-style: italic;">// For Messenger basic_communication example</span><br />
&nbsp; &nbsp; <span style="color: #000000;">&#125;</span><br />
&nbsp; &nbsp; <br />
&nbsp; &nbsp; <span style="color: #3f5fbf;">/*<br />
&nbsp; &nbsp; When you have a certain amount of values it will be smart to keep them<br />
&nbsp; &nbsp; in an array (so you only modify the array indexes that change.<br />
&nbsp; &nbsp; <br />
&nbsp; &nbsp; You can convert an array to a character seperated string (space character for <br />
&nbsp; &nbsp; Messenger library) with the join function.<br />
&nbsp; &nbsp; <br />
&nbsp; &nbsp; Example :<br />
&nbsp; &nbsp; var sendValues:Array = new Array(2,4,8,16,32,64,128);<br />
&nbsp; &nbsp; arduino.send(sendValues.join(&quot; &quot;));<br />
&nbsp; &nbsp; <br />
&nbsp; &nbsp; */</span><br />
<span style="color: #000000;">&#125;</span><br />
<br />
<span style="color: #009900; font-style: italic;">// add some balls to the stage to display incoming analog values</span><br />
<span style="color: #6699cc; font-weight: bold;">var</span> ballArray = <span style="color: #0033ff; font-weight: bold;">new</span> <span style="color: #004993;">Array</span><span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span><br />
<br />
<span style="color: #0033ff; font-weight: bold;">for</span><span style="color: #000000;">&#40;</span><span style="color: #6699cc; font-weight: bold;">var</span> i<span style="color: #000066; font-weight: bold;">:</span><span style="color: #004993;">int</span> = <span style="color: #000000; font-weight:bold;">0</span><span style="color: #000066; font-weight: bold;">;</span>i<span style="color: #000066; font-weight: bold;">&lt;</span><span style="color: #000000; font-weight:bold;">6</span><span style="color: #000066; font-weight: bold;">;</span>i<span style="color: #000066; font-weight: bold;">++</span><span style="color: #000000;">&#41;</span><br />
<span style="color: #000000;">&#123;</span> &nbsp; <br />
&nbsp; &nbsp; <span style="color: #6699cc; font-weight: bold;">var</span> ball<span style="color: #000066; font-weight: bold;">:</span><span style="color: #004993;">MovieClip</span> = <span style="color: #0033ff; font-weight: bold;">new</span> Ball<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span><br />
&nbsp; &nbsp; ballArray<span style="color: #000000;">&#91;</span>i<span style="color: #000000;">&#93;</span> = ball<span style="color: #000066; font-weight: bold;">;</span><br />
&nbsp; &nbsp; ball<span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">width</span> = ball<span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">height</span> = <span style="color: #000000; font-weight:bold;">50</span><span style="color: #000066; font-weight: bold;">;</span><br />
&nbsp; &nbsp; ball<span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">y</span> = <span style="color: #000000; font-weight:bold;">10</span><span style="color: #000066; font-weight: bold;">;</span><br />
&nbsp; &nbsp; ball<span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">x</span> = <span style="color: #000000; font-weight:bold;">10</span><span style="color: #000066; font-weight: bold;">+</span><span style="color: #000000;">&#40;</span>i<span style="color: #000066; font-weight: bold;">*</span><span style="color: #000000; font-weight:bold;">60</span><span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span><br />
&nbsp; &nbsp; <span style="color: #004993;">addChild</span><span style="color: #000000;">&#40;</span>ball<span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span><br />
<span style="color: #000000;">&#125;</span><br />
<br />
<span style="color: #009900; font-style: italic;">// Called when data is received from the Arduino</span><br />
<span style="color: #339966; font-weight: bold;">function</span> onArduinoData<span style="color: #000000;">&#40;</span> event<span style="color: #000066; font-weight: bold;">:</span><span style="color: #004993;">DataEvent</span> <span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">:</span><span style="color: #0033ff; font-weight: bold;">void</span><br />
<span style="color: #000000;">&#123;</span> &nbsp; <br />
&nbsp; &nbsp; <span style="color: #004993;">trace</span><span style="color: #000000;">&#40;</span><span style="color: #990000;">&quot;received string : &quot;</span><span style="color: #000066; font-weight: bold;">,</span> event<span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">data</span> <span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span><br />
<br />
&nbsp; &nbsp; <span style="color: #3f5fbf;">/* The values from Arduino Messenger are space seperated values. We will <br />
&nbsp; &nbsp; &nbsp; &nbsp;store each value in the receivedValues array. &nbsp; &nbsp;<br />
&nbsp; &nbsp; */</span><br />
&nbsp; &nbsp; receivedValues = event<span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">data</span><span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">split</span><span style="color: #000000;">&#40;</span><span style="color: #990000;">&quot; &quot;</span><span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span> <br />
&nbsp; &nbsp; <br />
&nbsp; &nbsp; <span style="color: #009900; font-style: italic;">// change the y position of the balls on stage </span><br />
&nbsp; &nbsp; <span style="color: #0033ff; font-weight: bold;">for</span><span style="color: #000000;">&#40;</span><span style="color: #6699cc; font-weight: bold;">var</span> i<span style="color: #000066; font-weight: bold;">:</span><span style="color: #004993;">int</span> = <span style="color: #000000; font-weight:bold;">0</span><span style="color: #000066; font-weight: bold;">;</span>i<span style="color: #000066; font-weight: bold;">&lt;</span><span style="color: #000000; font-weight:bold;">6</span><span style="color: #000066; font-weight: bold;">;</span>i<span style="color: #000066; font-weight: bold;">++</span><span style="color: #000000;">&#41;</span><br />
&nbsp; &nbsp; <span style="color: #000000;">&#123;</span> <span style="color: #6699cc; font-weight: bold;">var</span> mc = ballArray<span style="color: #000000;">&#91;</span>i<span style="color: #000000;">&#93;</span><span style="color: #000066; font-weight: bold;">;</span><br />
&nbsp; &nbsp; &nbsp; mc<span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">y</span> = receivedValues<span style="color: #000000;">&#91;</span>i<span style="color: #000000;">&#93;</span> <span style="color: #000066; font-weight: bold;">*</span> <span style="color: #000000; font-weight:bold;">350</span><span style="color: #000066; font-weight: bold;">/</span><span style="color: #000000; font-weight:bold;">1023</span><span style="color: #000066; font-weight: bold;">;</span>&nbsp; <br />
&nbsp; &nbsp; <span style="color: #000000;">&#125;</span> &nbsp; <br />
<span style="color: #000000;">&#125;</span></div></td></tr></tbody></table></div>
</pre>
]]></content:encoded>
			<wfw:commentRss>http://www.kasperkamperman.com/blog/arduino-flash-communication-as3-messenger/feed/</wfw:commentRss>
		<slash:comments>5</slash:comments>
		</item>
		<item>
		<title>Arduino Flash communication AS3 &#8211; As3Glue bundle</title>
		<link>http://www.kasperkamperman.com/blog/arduino/arduino-flash-communication-as3/</link>
		<comments>http://www.kasperkamperman.com/blog/arduino/arduino-flash-communication-as3/#comments</comments>
		<pubDate>Fri, 19 Mar 2010 16:36:18 +0000</pubDate>
		<dc:creator>kasperkamperman</dc:creator>
				<category><![CDATA[Arduino]]></category>
		<category><![CDATA[Flash]]></category>

		<guid isPermaLink="false">http://www.kasperkamperman.com/?p=789</guid>
		<description><![CDATA[Video tutorial on how to setup communication between Arduino and Flash (Actionscript 3.0) with Firmata, As3Glue and Serialproxy. You can download a bundle with examples and the libraries/software. ]]></description>
			<content:encoded><![CDATA[<p><a href="http://www.kasperkamperman.com/blog/arduino/arduino-flash-communication-as3/"><em>Click here to view the embedded video.</em></a></p>
<p>I&#8217;ve created a Flash monitor application with As3Glue to make it easier to start with Flash Arduino communication.</p>
<p>Glue is an ActionScript 3.0 library that enables communication between Flash and Arduino boards with Firmata. Since Flash cannot interface the serial port directly we&#8217;ll use Serialproxy in between. Serialproxy converts incoming serial data the XMLsocket data. </p>
<p>The monitor is useful to check if all the connections are working good. You can monitor directly all the sensors and actuators connected to your Arduino board. </p>
<p>The example code file is a start point to program your own things controlled by Arduino. Its support the normal Arduino board and the Arduino Mega. </p>
<p>Included files :</p>
<ul>
<li><a href="http://code.google.com/p/as3glue/ ">AS3Glue</a> files (.net.eriksjodin.arduino)</li>
<li><a href="http://code.google.com/p/tinkerit/wiki/TinkerProxy">Tinkerproxy osx</a> (renamed to serproxy)</li>
<li><a href="http://cote.cc/blog/serialproxy-v014-can-use-com-ports-above-9">Serialproxy windows</a> (renamed to serproxy)</li>
<li>as3glue_standalone_monitor.app</li>
<li>as3glue_standalone_monitor.exe</li>
<li>as3glue_standalone_monitor.fla</li>
<li>as3glue_program-example.fla</li>
</ul>
<p>The Firmata library is included with Arduino itself. Make sure you use Arduino 018 or higher, because the Firmata library included in version 017 is not stable. </p>
<ul>
<li>Update (12-05-10, v1.3): I&#8217;ve updated the code for the support of two servo motors (pin 9 and pin 10).</li>
<li>Update (17-09-10, v1.5): Program example simplified. Now executables included and hosted on Google code.</li>
<li>Update (11-02-11, v1.6): Program example included state-change example. Arduino UNO connection example in serialproxy.cfg.</li>
<li>Update (20-10-11, v2.0): Included support for the Arduino Mega in the program example. Thanks to Mochammad Effendi.</li>
</ul>
<p>Download the zip-file : <a class="download" href='http://as3glue.googlecode.com/files/arduino_as3glue_bundle_v20.zip'>arduino_as3glue_bundle_v2.0</a></p>
<p><a href="http://www.kasperkamperman.com/wordpress_kk/wordpress_uploads/2010/03/screenshot_as3-example.jpg">
<img src="http://www.kasperkamperman.com/wordpress_kk/wordpress_uploads/2010/03/screenshot_as3-example.jpg" alt="" title="screenshot_as3-example" width="550" height="671" class="alignnone size-full wp-image-793" /></a></p>
]]></content:encoded>
			<wfw:commentRss>http://www.kasperkamperman.com/blog/arduino/arduino-flash-communication-as3/feed/</wfw:commentRss>
		<slash:comments>40</slash:comments>
		</item>
		<item>
		<title>Flash AS3 : Apply bitmap filters to a webcam image</title>
		<link>http://www.kasperkamperman.com/blog/flash-code/as3-apply-bitmap-filters-to-a-webcam-image/</link>
		<comments>http://www.kasperkamperman.com/blog/flash-code/as3-apply-bitmap-filters-to-a-webcam-image/#comments</comments>
		<pubDate>Wed, 10 Mar 2010 21:52:13 +0000</pubDate>
		<dc:creator>kasperkamperman</dc:creator>
				<category><![CDATA[Flash]]></category>

		<guid isPermaLink="false">http://www.kasperkamperman.com/?p=769</guid>
		<description><![CDATA[Simple (beginner-intermediate) Flash Actionscript 3.0 code example on how to apply a bitmap filter on a webcam image. Also image rotation and simple motion detection (activityLevel) is included. 
]]></description>
			<content:encoded><![CDATA[<p>Simple (beginner-intermediate) Flash AS3code example on how to apply a bitmap filter on a webcam image. Also image rotation and simple motion detection (activityLevel) is included. </p>
<p>You can make a Photobooth of this script as well. Mark Knol wrote an ImageSaver class that sends a .jpg or .png picture of a Display element to a simple PHP script that stores it on a webserver :<br/>
<a href="http://blog.stroep.nl/2008/08/as3-imagesaver-class-v10/">Stroep.nl AS3 ImageSaver Class</a>.</p>
<p>You need a webcam and give Flashplayer access to the camera to see the example below :</p>

<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000"
			id="fm_camera-example_319022400"
			class="flashmovie"
			width="400"
			height="300">
	<param name="movie" value="http://www.kasperkamperman.com/wordpress_kk/wordpress_uploads/2010/03/camera-example.swf" />
	<!--[if !IE]>-->
	<object	type="application/x-shockwave-flash"
			data="http://www.kasperkamperman.com/wordpress_kk/wordpress_uploads/2010/03/camera-example.swf"
			name="fm_camera-example_319022400"
			width="400"
			height="300">
	<!--<![endif]-->
		
<p><a href="http://get.adobe.com/flashplayer/"><img src="http://www.adobe.com/images/shared/download_buttons/get_flash_player.gif" alt="Get Adobe Flash player" /></a></p>

	<!--[if !IE]>-->
	</object>
	<!--<![endif]-->
</object>
<p><br/>
For more in-depth information see the following subjects in the Flash Actionscript 3.0 reference :</p>
<ul>
<li><a href="http://help.adobe.com/en_US/AS3LCR/Flash_10.0/flash/filters/package-detail.html">filters</a></li>
<li><a href="http://help.adobe.com/en_US/AS3LCR/Flash_10.0/flash/display/BitmapData.html">bitmapdata </a></li>
<li><a href="http://help.adobe.com/en_US/AS3LCR/Flash_10.0/flash/media/Camera.html">camera</a></li>
</ul>
<h2>The code ( copy-paste directly in a new Flash project in the Actions &#8211; Frame. )</h2>
<pre>
<div class="codecolorer-container actionscript3 default" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;height:450px;"><table cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:5px;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;font: normal 12px/1.4em Monaco, Lucida Console, monospace;"><div>1<br />2<br />3<br />4<br />5<br />6<br />7<br />8<br />9<br />10<br />11<br />12<br />13<br />14<br />15<br />16<br />17<br />18<br />19<br />20<br />21<br />22<br />23<br />24<br />25<br />26<br />27<br />28<br />29<br />30<br />31<br />32<br />33<br />34<br />35<br />36<br />37<br />38<br />39<br />40<br />41<br />42<br />43<br />44<br />45<br />46<br />47<br />48<br />49<br />50<br />51<br />52<br />53<br />54<br />55<br />56<br />57<br />58<br />59<br />60<br />61<br />62<br />63<br />64<br />65<br />66<br />67<br />68<br />69<br />70<br />71<br />72<br />73<br />74<br />75<br />76<br />77<br />78<br />79<br />80<br /></div></td><td><div class="actionscript3 codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color: #3f5fbf;">/*<br />
Example how to detect motion in a webcam image and to apply a color filter <br />
and/or rotation. <br />
<br />
www.kasperkamperman.com - 10-03-2010<br />
*/</span><br />
<br />
<span style="color: #6699cc; font-weight: bold;">var</span> <span style="color: #004993;">fps</span><span style="color: #000066; font-weight: bold;">:</span><span style="color: #004993;">int</span> = <span style="color: #000000; font-weight:bold;">25</span><span style="color: #000066; font-weight: bold;">;</span> <span style="color: #009900; font-style: italic;">// frames per second you want to grab and display</span><br />
<br />
<span style="color: #6699cc; font-weight: bold;">var</span> cam<span style="color: #000066; font-weight: bold;">:</span><span style="color: #004993;">Camera</span><span style="color: #000066; font-weight: bold;">;</span><br />
cam = <span style="color: #004993;">Camera</span><span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">getCamera</span><span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span><br />
cam<span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">setMode</span><span style="color: #000000;">&#40;</span><span style="color: #000000; font-weight:bold;">640</span><span style="color: #000066; font-weight: bold;">,</span><span style="color: #000000; font-weight:bold;">480</span><span style="color: #000066; font-weight: bold;">,</span><span style="color: #004993;">fps</span><span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span><br />
<br />
<span style="color: #6699cc; font-weight: bold;">var</span> video<span style="color: #000066; font-weight: bold;">:</span><span style="color: #004993;">Video</span><span style="color: #000066; font-weight: bold;">;</span><br />
video = <span style="color: #0033ff; font-weight: bold;">new</span> <span style="color: #004993;">Video</span><span style="color: #000000;">&#40;</span>cam<span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">width</span><span style="color: #000066; font-weight: bold;">,</span> cam<span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">height</span><span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span><br />
video<span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">attachCamera</span><span style="color: #000000;">&#40;</span>cam<span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span><br />
<br />
<span style="color: #009900; font-style: italic;">// motion detector ------------------------------------------------</span><br />
cam<span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">setMotionLevel</span><span style="color: #000000;">&#40;</span><span style="color: #000000; font-weight:bold;">30</span><span style="color: #000066; font-weight: bold;">,</span> <span style="color: #000000; font-weight:bold;">100</span><span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span> <span style="color: #009900; font-style: italic;">// level 30, timer 500ms</span><br />
cam<span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">addEventListener</span><span style="color: #000000;">&#40;</span><span style="color: #004993;">ActivityEvent</span><span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">ACTIVITY</span><span style="color: #000066; font-weight: bold;">,</span> activityHandler<span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span><br />
<br />
<span style="color: #009900; font-style: italic;">// variable to store movement ( use later to apply the filter )</span><br />
<span style="color: #6699cc; font-weight: bold;">var</span> imageMovement<span style="color: #000066; font-weight: bold;">:</span><span style="color: #004993;">Boolean</span> = <span style="color: #0033ff; font-weight: bold;">false</span><span style="color: #000066; font-weight: bold;">;</span> <br />
<br />
<span style="color: #339966; font-weight: bold;">function</span> activityHandler<span style="color: #000000;">&#40;</span>e<span style="color: #000066; font-weight: bold;">:</span><span style="color: #004993;">ActivityEvent</span><span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">:</span><span style="color: #0033ff; font-weight: bold;">void</span> <br />
<span style="color: #000000;">&#123;</span> &nbsp;<span style="color: #0033ff; font-weight: bold;">if</span> <span style="color: #000000;">&#40;</span>e<span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">activating</span> == <span style="color: #0033ff; font-weight: bold;">true</span><span style="color: #000000;">&#41;</span> <span style="color: #000000;">&#123;</span><br />
&nbsp; &nbsp; imageMovement = <span style="color: #0033ff; font-weight: bold;">true</span><span style="color: #000066; font-weight: bold;">;</span><br />
&nbsp; &nbsp; <span style="color: #004993;">trace</span><span style="color: #000000;">&#40;</span><span style="color: #990000;">&quot;movement above threshold. Level :&quot;</span><span style="color: #000066; font-weight: bold;">+</span>cam<span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">activityLevel</span><span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span><br />
&nbsp; &nbsp;<span style="color: #000000;">&#125;</span> <span style="color: #0033ff; font-weight: bold;">else</span> <span style="color: #000000;">&#123;</span><br />
&nbsp; &nbsp; imageMovement = <span style="color: #0033ff; font-weight: bold;">false</span><span style="color: #000066; font-weight: bold;">;</span><br />
&nbsp; &nbsp; <span style="color: #004993;">trace</span><span style="color: #000000;">&#40;</span><span style="color: #990000;">&quot;no movement. Level :&quot;</span><span style="color: #000066; font-weight: bold;">+</span>cam<span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">activityLevel</span><span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span><br />
&nbsp; &nbsp;<span style="color: #000000;">&#125;</span> &nbsp; &nbsp;<br />
<span style="color: #000000;">&#125;</span><br />
<br />
<span style="color: #009900; font-style: italic;">// --- filter ---------------------------------------------------------</span><br />
<br />
<span style="color: #009900; font-style: italic;">// filter green/blue components ( leave red)</span><br />
<span style="color: #6699cc; font-weight: bold;">var</span> redFilterMatrix<span style="color: #000066; font-weight: bold;">:</span><span style="color: #004993;">Array</span> = <span style="color: #0033ff; font-weight: bold;">new</span> <span style="color: #004993;">Array</span><span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span><br />
redFilterMatrix = redFilterMatrix<span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">concat</span><span style="color: #000000;">&#40;</span><span style="color: #000000;">&#91;</span><span style="color: #000000; font-weight:bold;">1</span><span style="color: #000066; font-weight: bold;">,</span> <span style="color: #000000; font-weight:bold;">0</span><span style="color: #000066; font-weight: bold;">,</span> <span style="color: #000000; font-weight:bold;">0</span><span style="color: #000066; font-weight: bold;">,</span> <span style="color: #000000; font-weight:bold;">0</span><span style="color: #000066; font-weight: bold;">,</span> <span style="color: #000000; font-weight:bold;">0</span><span style="color: #000000;">&#93;</span><span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span> <span style="color: #009900; font-style: italic;">// red</span><br />
redFilterMatrix = redFilterMatrix<span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">concat</span><span style="color: #000000;">&#40;</span><span style="color: #000000;">&#91;</span><span style="color: #000000; font-weight:bold;">0</span><span style="color: #000066; font-weight: bold;">,</span> <span style="color: #000000; font-weight:bold;">0</span><span style="color: #000066; font-weight: bold;">,</span> <span style="color: #000000; font-weight:bold;">0</span><span style="color: #000066; font-weight: bold;">,</span> <span style="color: #000000; font-weight:bold;">0</span><span style="color: #000066; font-weight: bold;">,</span> <span style="color: #000000; font-weight:bold;">0</span><span style="color: #000000;">&#93;</span><span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span> <span style="color: #009900; font-style: italic;">// green</span><br />
redFilterMatrix = redFilterMatrix<span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">concat</span><span style="color: #000000;">&#40;</span><span style="color: #000000;">&#91;</span><span style="color: #000000; font-weight:bold;">0</span><span style="color: #000066; font-weight: bold;">,</span> <span style="color: #000000; font-weight:bold;">0</span><span style="color: #000066; font-weight: bold;">,</span> <span style="color: #000000; font-weight:bold;">0</span><span style="color: #000066; font-weight: bold;">,</span> <span style="color: #000000; font-weight:bold;">0</span><span style="color: #000066; font-weight: bold;">,</span> <span style="color: #000000; font-weight:bold;">0</span><span style="color: #000000;">&#93;</span><span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span> <span style="color: #009900; font-style: italic;">// blue</span><br />
redFilterMatrix = redFilterMatrix<span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">concat</span><span style="color: #000000;">&#40;</span><span style="color: #000000;">&#91;</span><span style="color: #000000; font-weight:bold;">0</span><span style="color: #000066; font-weight: bold;">,</span> <span style="color: #000000; font-weight:bold;">0</span><span style="color: #000066; font-weight: bold;">,</span> <span style="color: #000000; font-weight:bold;">0</span><span style="color: #000066; font-weight: bold;">,</span> <span style="color: #000000; font-weight:bold;">1</span><span style="color: #000066; font-weight: bold;">,</span> <span style="color: #000000; font-weight:bold;">0</span><span style="color: #000000;">&#93;</span><span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span> <span style="color: #009900; font-style: italic;">// alpha</span><br />
<br />
<span style="color: #6699cc; font-weight: bold;">var</span> <span style="color: #004993;">filter</span><span style="color: #000066; font-weight: bold;">:</span><span style="color: #004993;">ColorMatrixFilter</span> = <span style="color: #0033ff; font-weight: bold;">new</span> <span style="color: #004993;">ColorMatrixFilter</span><span style="color: #000000;">&#40;</span>redFilterMatrix<span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span><br />
<br />
<span style="color: #009900; font-style: italic;">// --- BitmapData ------------------------</span><br />
<br />
<span style="color: #009900; font-style: italic;">// make a BitmapData object on which you can draw to video</span><br />
<span style="color: #009900; font-style: italic;">// ( exchange width/height when you want to rotate the image )</span><br />
<span style="color: #6699cc; font-weight: bold;">var</span> bmd<span style="color: #000066; font-weight: bold;">:</span><span style="color: #004993;">BitmapData</span> = <span style="color: #0033ff; font-weight: bold;">new</span> <span style="color: #004993;">BitmapData</span><span style="color: #000000;">&#40;</span>cam<span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">width</span><span style="color: #000066; font-weight: bold;">,</span>cam<span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">height</span><span style="color: #000066; font-weight: bold;">,</span><span style="color: #0033ff; font-weight: bold;">false</span><span style="color: #000066; font-weight: bold;">,</span><span style="color: #000000; font-weight:bold;">0</span><span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span><br />
<br />
<span style="color: #009900; font-style: italic;">// rectangle and pointer for applying filter</span><br />
<span style="color: #6699cc; font-weight: bold;">var</span> <span style="color: #004993;">rect</span><span style="color: #000066; font-weight: bold;">:</span><span style="color: #004993;">Rectangle</span> = <span style="color: #0033ff; font-weight: bold;">new</span> <span style="color: #004993;">Rectangle</span><span style="color: #000000;">&#40;</span><span style="color: #000000; font-weight:bold;">0</span><span style="color: #000066; font-weight: bold;">,</span> <span style="color: #000000; font-weight:bold;">0</span><span style="color: #000066; font-weight: bold;">,</span> bmd<span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">width</span><span style="color: #000066; font-weight: bold;">,</span> bmd<span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">height</span><span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span><br />
<span style="color: #6699cc; font-weight: bold;">var</span> point<span style="color: #000066; font-weight: bold;">:</span><span style="color: #004993;">Point</span> = <span style="color: #0033ff; font-weight: bold;">new</span> <span style="color: #004993;">Point</span><span style="color: #000000;">&#40;</span><span style="color: #000000; font-weight:bold;">0</span><span style="color: #000066; font-weight: bold;">,</span> <span style="color: #000000; font-weight:bold;">0</span><span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span><br />
<br />
<span style="color: #6699cc; font-weight: bold;">var</span> canvasBitmap<span style="color: #000066; font-weight: bold;">:</span><span style="color: #004993;">Bitmap</span> = <span style="color: #0033ff; font-weight: bold;">new</span> <span style="color: #004993;">Bitmap</span><span style="color: #000000;">&#40;</span>bmd<span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span> <span style="color: #009900; font-style: italic;">// link BitmapData to Bitmap </span><br />
<span style="color: #004993;">addChild</span><span style="color: #000000;">&#40;</span>canvasBitmap<span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #009900; font-style: italic;">// add Bitmap to stage</span><br />
<br />
<span style="color: #009900; font-style: italic;">// --- rotate camera image ---------------------------------------------------</span><br />
<br />
<span style="color: #6699cc; font-weight: bold;">var</span> rotateMatrix<span style="color: #000066; font-weight: bold;">:</span><span style="color: #004993;">Matrix</span> = <span style="color: #0033ff; font-weight: bold;">new</span> <span style="color: #004993;">Matrix</span><span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span><br />
rotateMatrix<span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">rotate</span><span style="color: #000000;">&#40;</span><span style="color: #000000; font-weight:bold;">2</span> <span style="color: #000066; font-weight: bold;">*</span> <span style="color: #004993;">Math</span><span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">PI</span> <span style="color: #000066; font-weight: bold;">*</span> <span style="color: #000000;">&#40;</span><span style="color: #000000; font-weight:bold;">90</span> <span style="color: #000066; font-weight: bold;">/</span> <span style="color: #000000; font-weight:bold;">360</span><span style="color: #000000;">&#41;</span><span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span><br />
rotateMatrix<span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">translate</span><span style="color: #000000;">&#40;</span>cam<span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">height</span><span style="color: #000066; font-weight: bold;">,</span><span style="color: #000000; font-weight:bold;">0</span><span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span><br />
<br />
<span style="color: #009900; font-style: italic;">// --- Timer to refresh the image --------------------------------------------</span><br />
<span style="color: #6699cc; font-weight: bold;">var</span> refreshTimer<span style="color: #000066; font-weight: bold;">:</span><span style="color: #004993;">Timer</span> = <span style="color: #0033ff; font-weight: bold;">new</span> <span style="color: #004993;">Timer</span><span style="color: #000000;">&#40;</span><span style="color: #000000; font-weight:bold;">1000</span><span style="color: #000066; font-weight: bold;">/</span><span style="color: #000000; font-weight:bold;">25</span><span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span> <span style="color: #009900; font-style: italic;">// 1000ms / 25fps</span><br />
refreshTimer<span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">start</span><span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span><br />
refreshTimer<span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">addEventListener</span><span style="color: #000000;">&#40;</span><span style="color: #004993;">TimerEvent</span><span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">TIMER</span><span style="color: #000066; font-weight: bold;">,</span> imageRefresh<span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span><br />
<br />
<span style="color: #339966; font-weight: bold;">function</span> imageRefresh<span style="color: #000000;">&#40;</span>e<span style="color: #000066; font-weight: bold;">:</span><span style="color: #004993;">Event</span><span style="color: #000000;">&#41;</span><br />
<span style="color: #000000;">&#123;</span> &nbsp; &nbsp;<span style="color: #009900; font-style: italic;">// draw video on BitmapData</span><br />
&nbsp; &nbsp; &nbsp;bmd<span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">draw</span><span style="color: #000000;">&#40;</span>video<span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span><br />
&nbsp; &nbsp; &nbsp;<br />
&nbsp; &nbsp; &nbsp;<span style="color: #009900; font-style: italic;">// draw video rotated on BitmapData ( don't forget to change BitmapData to </span><br />
&nbsp; &nbsp; &nbsp;<span style="color: #009900; font-style: italic;">// the right size ) and comment the bmd.draw(video) line. </span><br />
&nbsp; &nbsp; &nbsp;<span style="color: #009900; font-style: italic;">//bmd.draw(video, rotateMatrix);</span><br />
&nbsp; &nbsp; &nbsp;<br />
&nbsp; &nbsp; &nbsp;<span style="color: #009900; font-style: italic;">// apply the red filter when there is enough image movement</span><br />
&nbsp; &nbsp; &nbsp;<span style="color: #0033ff; font-weight: bold;">if</span><span style="color: #000000;">&#40;</span>imageMovement==<span style="color: #0033ff; font-weight: bold;">true</span><span style="color: #000000;">&#41;</span> bmd<span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">applyFilter</span><span style="color: #000000;">&#40;</span>bmd<span style="color: #000066; font-weight: bold;">,</span><span style="color: #004993;">rect</span><span style="color: #000066; font-weight: bold;">,</span>point<span style="color: #000066; font-weight: bold;">,</span><span style="color: #004993;">filter</span><span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span>&nbsp; &nbsp; <br />
<span style="color: #000000;">&#125;</span></div></td></tr></tbody></table></div>
</pre>
]]></content:encoded>
			<wfw:commentRss>http://www.kasperkamperman.com/blog/flash-code/as3-apply-bitmap-filters-to-a-webcam-image/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Arduino Flash communication AS2</title>
		<link>http://www.kasperkamperman.com/blog/arduino/arduino-flash-communication/</link>
		<comments>http://www.kasperkamperman.com/blog/arduino/arduino-flash-communication/#comments</comments>
		<pubDate>Mon, 15 Dec 2008 09:50:54 +0000</pubDate>
		<dc:creator>kasperkamperman</dc:creator>
				<category><![CDATA[Arduino]]></category>
		<category><![CDATA[Flash]]></category>
		<category><![CDATA[arduino flash communition]]></category>
		<category><![CDATA[art & technology]]></category>
		<category><![CDATA[as2]]></category>
		<category><![CDATA[flash]]></category>
		<category><![CDATA[kunst & techniek]]></category>
		<category><![CDATA[linkedin]]></category>
		<category><![CDATA[playground]]></category>
		<category><![CDATA[saxion]]></category>
		<category><![CDATA[serial proxy]]></category>
		<category><![CDATA[tutorial]]></category>

		<guid isPermaLink="false">http://127.0.0.1/?p=60</guid>
		<description><![CDATA[In this video tutorial I explain how to setup communication between the Arduino microcontroller board and Flash ( Actionscript 2). Example files are included.]]></description>
			<content:encoded><![CDATA[<p><a href="http://www.kasperkamperman.com/blog/arduino/arduino-flash-communication/"><em>Click here to view the embedded video.</em></a></p>
<p>Tutorial that explains how to setup communication between Arduino and Flash with provided example files. </p>
<p>Update : See <a href="http://www.kasperkamperman.com/blog/arduino/arduino-flash-communication-as3/">Arduino Flash communication AS3 &#8211; As3Glue bundle</a> for an Actionscript 3 tutorial. </p>
<p>You can read sensors connected to the Arduino in Flash and send output information to actuators connected to the Arduino. Communication between Flash and Arduino is setup with the Serialproxy program that converts serial strings in to XML socket data.</p>
<p>The zip package can be download from :
<a href="http://arduino.cc/playground/uploads/Interfacing/flash_arduino_io_2.zip">arduino.cc/playground/uploads/Interfacing/flash_arduino_io_2.zip</a></p>
<p><strong>UPDATE :</strong>
<em>Serialproxy doesn&#8217;t work anymore under Snow Leopard ( osx 10.6 ) without installing Rosetta.
However you can also use Tinkerproxy2. That works in the same way as Serialproxy.
Just rename your serproxy.cfg to tinkerproxy2.cfg or you can rename the program tinkerproxy2 to serproxy.</em>
<a href="http://code.google.com/p/tinkerit/downloads/detail?name=tinkerproxy-2_0.zip">tinkerproxy-2_0.zip</a></p>
<p>See the Playground in Arduino for more Flash implementations :
<a href="http://arduino.cc/playground/Interfacing/Flash/">arduino.cc/playground/Interfacing/Flash/</a></p>
]]></content:encoded>
			<wfw:commentRss>http://www.kasperkamperman.com/blog/arduino/arduino-flash-communication/feed/</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
	</channel>
</rss>

