<?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>Spreading Funkyness &#187; programming</title>
	<atom:link href="http://spreadingfunkyness.com/category/programming/feed/" rel="self" type="application/rss+xml" />
	<link>http://spreadingfunkyness.com</link>
	<description>RIAbilitating the Internet with web apps, ria, iphone and ipad apps.</description>
	<lastBuildDate>Wed, 04 Jan 2012 10:20:57 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=</generator>
<cloud domain='spreadingfunkyness.com' port='80' path='/?rsscloud=notify' registerProcedure='' protocol='http-post' />
		<item>
		<title>Don&#8217;t Upgrade to Mac OS Lion! (Not yet)</title>
		<link>http://spreadingfunkyness.com/dont-upgrade-to-mac-os-lion-not-yet/</link>
		<comments>http://spreadingfunkyness.com/dont-upgrade-to-mac-os-lion-not-yet/#comments</comments>
		<pubDate>Fri, 29 Jul 2011 13:10:33 +0000</pubDate>
		<dc:creator>Cesare</dc:creator>
				<category><![CDATA[apple]]></category>
		<category><![CDATA[productivity]]></category>
		<category><![CDATA[programming]]></category>

		<guid isPermaLink="false">http://spreadingfunkyness.com/?p=350</guid>
		<description><![CDATA[New is cool. I like to try new things, even alpha or beta stuff. I like to see changes, improvements, new directions. I like the way Apple continuously pushes improvements: one new iDevice almost each year, new software solutions, new ways to save data. But I can&#8217;t let the things I like to influence my ...]]></description>
			<content:encoded><![CDATA[<div class="tweetmeme_button" style="float: left; margin: 0px 10px 0px 0px;">
			<a href="http://api.tweetmeme.com/share?url=http%3A%2F%2Fspreadingfunkyness.com%2Fdont-upgrade-to-mac-os-lion-not-yet%2F"><br />
				<img src="http://api.tweetmeme.com/imagebutton.gif?url=http%3A%2F%2Fspreadingfunkyness.com%2Fdont-upgrade-to-mac-os-lion-not-yet%2F&amp;source=_funkyboy&amp;style=normal&amp;service=bit.ly&amp;b=2" height="61" width="50" /><br />
			</a>
		</div>
<p>New is cool. I like to try new things, even alpha or beta stuff. I like to see changes, improvements, new directions. I like the way Apple continuously pushes improvements: one new iDevice almost each year, new software solutions, new ways to save data. But I can&#8217;t let the things I like to influence my business in a bad way.<br />
If you are like me you probably have a machine (in my case a MacBook Pro) which is your faithful daily companion. There is everything you need, the tools you use daily. An operative systems is not a toy application you can live without. It&#8217;s part of  that faithful companion, something you count on. <strong>OSX Lion is something I cannot count on yet</strong>. I installed it on a spare Mac mini, which I use for experiments. I like the new interface, the way it is inspired to iOS, the way it is easier to use. But there are tools I work with daily, which are still not fully compatible with Lion.<strong> The first release of new tool is not perfect</strong>, even if it has been extensively tested during the alpha and beta stages. This happens to each product, even if it is built by great developers. Check out the Mac or App store to see how many 1.0.1 or 2.1 versions you can spot. Those minor version changes reflect updates which are needed to improve and fine-tune applications. Not even Apple is immune to that. I bet there will be a Lion 10.7.1 soon. The same applies to other Apple products like XCode. That&#8217;s another tool I use daily. There has been a 4.0, then a 4.0.1, a 4.0.2 and now a 4.1. If you search the Twitterverse it&#8217;s easy to spot people lamenting crashes of Lion or XCode. I can even venture a bet that <strong>50% of Apple developers is still using XCode 3</strong>.<br />
Not to mention 3rd party apps. Part of my daily job is based on the Adobe Creative Suite, which sometimes is buggy per se, regardless of the OS. I don&#8217;t want even imagine how it behaves on Lion, considering that <a href="http://www.wired.com/epicenter/2010/01/googles-dont-be-evil-mantra-is-bullshit-adobe-is-lazy-apples-steve-jobs/">Adobe is lazy</a> (BTW compatibility issues are listed <a href="http://kb2.adobe.com/cps/905/cpsid_90508.html">here</a>) Also historically known applications like <a href="http://panic.com/coda/">Coda</a> are unstable and crashy, in spite the fact it has been upgraded to be Lion compatible. See <a href="https://twitter.com/#!/zhephree/status/96772348270743552">here</a> and <a href="https://twitter.com/#!/jacobdubail/status/96713669915852800">here</a> for example. I remember I had the same approach to Snow Leopard, which I installed at least two months after the first release. </p>
<p>I can understand people which install Lion to test it or <a href="http://www.guardian.co.uk/technology/2011/jul/20/mac-osx-lion-review">review it</a>. But really, <strong>what&#8217;s the sense of installing it and polluting the Twitterverse like screaming kids? Software development is craftsmanship, it takes time</strong>. Or is Apple so trustful that people blindly upgrade without doing any check?<br />
Personally I can support an application crash a week, and a kernel panic error a month. Something more frequent would kill my productivity and raise my stress. My suggestion is to wait at least the next minor release. Moreover:</p>
<ul>
<li>monitor relevant twitterers and bloggers to have a glimpse of the current situation
</li>
<li>talk to people you trust, ask them how is the current release,
</li>
<li>monitor Apple&#8217;s forums,
</li>
<li>check the website/forums of each application you use for your business
</li>
</ul>
<p><strong>And even after that be a bit doubtful</strong>. We are talking business. Or would you prefer to tell your client that the last release got screwed due to <del datetime="2011-07-29T15:24:57+00:00">a Lion crash</del> an app crashing on Lion? :)<br />
That said, when do you plan to install Lion? Did you already install it? How many issues did you have?</p>
<p>Update.<br />
If you like to check whether an app is compatible with Lion you can consult <a href="http://roaringapps.com/">roaringapps</a></p>
<p><a class="a2a_dd a2a_target addtoany_share_save" href="http://www.addtoany.com/share_save#url=http%3A%2F%2Fspreadingfunkyness.com%2Fdont-upgrade-to-mac-os-lion-not-yet%2F&amp;title=Don%26%238217%3Bt%20Upgrade%20to%20Mac%20OS%20Lion%21%20%28Not%20yet%29" id="wpa2a_2"><img src="http://spreadingfunkyness.com/wp-content/plugins/add-to-any/share_save_120_16.gif" width="120" height="16" alt="Share"/></a></p>]]></content:encoded>
			<wfw:commentRss>http://spreadingfunkyness.com/dont-upgrade-to-mac-os-lion-not-yet/feed/</wfw:commentRss>
		<slash:comments>5</slash:comments>
		</item>
		<item>
		<title>6 Tutorials on Copy&amp;Paste and Drag&amp;Drop in Adobe Air</title>
		<link>http://spreadingfunkyness.com/6-tutorials-on-copypaste-and-dragdrop-in-adobe-air/</link>
		<comments>http://spreadingfunkyness.com/6-tutorials-on-copypaste-and-dragdrop-in-adobe-air/#comments</comments>
		<pubDate>Fri, 05 Feb 2010 13:32:20 +0000</pubDate>
		<dc:creator>Cesare</dc:creator>
				<category><![CDATA[actionscript]]></category>
		<category><![CDATA[adobeair]]></category>
		<category><![CDATA[flex]]></category>
		<category><![CDATA[programming]]></category>

		<guid isPermaLink="false">http://spreadingfunkyness.com/?p=308</guid>
		<description><![CDATA[I recently published a series of tutorials around the topic of &#8220;moving stuff&#8221; across Adobe Air applications (via copy&#038;paste and drag&#038;drop). Here is the complete list of all the tutorials. Native Drag and Drop in Adobe Air The first tutorial, to get started with drag and drop. Drag and Drop of Text in Adobe Air ...]]></description>
			<content:encoded><![CDATA[<div class="tweetmeme_button" style="float: left; margin: 0px 10px 0px 0px;">
			<a href="http://api.tweetmeme.com/share?url=http%3A%2F%2Fspreadingfunkyness.com%2F6-tutorials-on-copypaste-and-dragdrop-in-adobe-air%2F"><br />
				<img src="http://api.tweetmeme.com/imagebutton.gif?url=http%3A%2F%2Fspreadingfunkyness.com%2F6-tutorials-on-copypaste-and-dragdrop-in-adobe-air%2F&amp;source=_funkyboy&amp;style=normal&amp;service=bit.ly&amp;b=2" height="61" width="50" /><br />
			</a>
		</div>
<p>I recently published a series of tutorials around the topic of &#8220;moving stuff&#8221; across Adobe Air applications (via copy&#038;paste and drag&#038;drop). Here is the complete list of all the tutorials.</p>
<ul>
<li><a href="http://spreadingfunkyness.com/native-drag-and-drop-in-adobe-air/">Native Drag and Drop in Adobe Air</a><br />
The first tutorial, to get started with drag and drop.</li>
<li><a href="http://spreadingfunkyness.com/drag-and-drop-of-text-in-adobe-air/">Drag and Drop of Text in Adobe Air</a><br />
An overview of how to drag and drop textual content in Adobe Air.</li>
<li><a href="http://spreadingfunkyness.com/drag-and-drop-of-images-in-adobe-air/">Drag and Drop of Images In Adobe Air</a><br />
A tutorial on drag and drop from OS to Adobe air and across Air apps.</li>
<li><a href="http://spreadingfunkyness.com/copy-and-paste-images-in-adobe-air/">Copy and Paste Images in Adobe Air</a><br />
The first tutorial on copy and paste, focused on images.</li>
<li><a href="http://spreadingfunkyness.com/copy-and-paste-a-complex-object-in-adobe-air/">Copy and Paste a complex object in Adobe Air</a><br />
Description of how to move a custom object across Adobe Air applications.
</li>
<li><a href="http://spreadingfunkyness.com/copy-and-paste-sets-of-complex-objects-in-adobe-air/">Copy and Paste Sets of Complex Objects in Adobe Air</a><br />
A tutorial about how to copy and paste arrays of custom objects.
</li>
</ul>
<p>I am planning to release more series about Adobe Air/Flex. Any topic your prefer? Leave a comment below or contact me.</p>
<p><a class="a2a_dd a2a_target addtoany_share_save" href="http://www.addtoany.com/share_save#url=http%3A%2F%2Fspreadingfunkyness.com%2F6-tutorials-on-copypaste-and-dragdrop-in-adobe-air%2F&amp;title=6%20Tutorials%20on%20Copy%26%23038%3BPaste%20and%20Drag%26%23038%3BDrop%20in%20Adobe%20Air" id="wpa2a_4"><img src="http://spreadingfunkyness.com/wp-content/plugins/add-to-any/share_save_120_16.gif" width="120" height="16" alt="Share"/></a></p>]]></content:encoded>
			<wfw:commentRss>http://spreadingfunkyness.com/6-tutorials-on-copypaste-and-dragdrop-in-adobe-air/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Copy and Paste Sets of Complex Objects in Adobe Air</title>
		<link>http://spreadingfunkyness.com/copy-and-paste-sets-of-complex-objects-in-adobe-air/</link>
		<comments>http://spreadingfunkyness.com/copy-and-paste-sets-of-complex-objects-in-adobe-air/#comments</comments>
		<pubDate>Fri, 29 Jan 2010 13:37:27 +0000</pubDate>
		<dc:creator>Cesare</dc:creator>
				<category><![CDATA[actionscript]]></category>
		<category><![CDATA[adobeair]]></category>
		<category><![CDATA[flex]]></category>
		<category><![CDATA[programming]]></category>

		<guid isPermaLink="false">http://spreadingfunkyness.com/?p=306</guid>
		<description><![CDATA[This is a followup post to the <a href="http://spreadingfunkyness.com/copy-and-paste-a-complex-object-in-adobe-air/">previous one</a>, where we have seen how to copy and paste a complex object across two Adobe Air applications. We will see how to copy and paste more than one object from an Adobe Air application to another]]></description>
			<content:encoded><![CDATA[<div class="tweetmeme_button" style="float: left; margin: 0px 10px 0px 0px;">
			<a href="http://api.tweetmeme.com/share?url=http%3A%2F%2Fspreadingfunkyness.com%2Fcopy-and-paste-sets-of-complex-objects-in-adobe-air%2F"><br />
				<img src="http://api.tweetmeme.com/imagebutton.gif?url=http%3A%2F%2Fspreadingfunkyness.com%2Fcopy-and-paste-sets-of-complex-objects-in-adobe-air%2F&amp;source=_funkyboy&amp;style=normal&amp;service=bit.ly&amp;b=2" height="61" width="50" /><br />
			</a>
		</div>
<p>This is a followup post to the <a href="http://spreadingfunkyness.com/copy-and-paste-a-complex-object-in-adobe-air/">previous one</a>, where we have seen how to copy and paste a complex object across two Adobe Air applications. We will see how to copy and paste more than one object from an Adobe Air application to another. First of all we have to enable multiple selection in our Datagrid, that&#8217;s easy.</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
</pre></td><td class="code"><pre class="actionscript" style="font-family:monospace;"><span style="color: #66cc66;">&lt;</span>mx:DataGrid id=<span style="color: #ff0000;">&quot;grid&quot;</span> 
	dataProvider=<span style="color: #ff0000;">&quot;{collection}&quot;</span>
	allowMultipleSelection=<span style="color: #ff0000;">&quot;true&quot;</span> <span style="color: #66cc66;">&gt;</span></pre></td></tr></table></div>

<p>We then modify the function that copies data to the clipboard. Instead of a single element we want the list of the selected items in the datagrid (line 3).</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
</pre></td><td class="code"><pre class="actionscript" style="font-family:monospace;"><span style="color: #0066CC;">private</span> <span style="color: #000000; font-weight: bold;">function</span> copyToClipboard<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>:<span style="color: #0066CC;">void</span> <span style="color: #66cc66;">&#123;</span>
&nbsp;
	<span style="color: #000000; font-weight: bold;">var</span> <span style="color: #0066CC;">selection</span>:ArrayCollection = <span style="color: #000000; font-weight: bold;">new</span> ArrayCollection<span style="color: #66cc66;">&#40;</span>grid.<span style="color: #006600;">selectedItems</span><span style="color: #66cc66;">&#41;</span>;
	Clipboard.<span style="color: #006600;">generalClipboard</span>.<span style="color: #0066CC;">clear</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>;
	Clipboard.<span style="color: #006600;">generalClipboard</span>.<span style="color: #006600;">setData</span><span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">&quot;myCustomFormat&quot;</span>, <span style="color: #0066CC;">selection</span><span style="color: #66cc66;">&#41;</span>;
	feedback.<span style="color: #0066CC;">text</span> = <span style="color: #ff0000;">&quot;Data copied to the clipboard&quot;</span>;
&nbsp;
<span style="color: #66cc66;">&#125;</span></pre></td></tr></table></div>

<p>The rest of the code remains the same of the <a href="http://spreadingfunkyness.com/copy-and-paste-a-complex-object-in-adobe-air/">previous tutorial</a>. The destination application needs a bit more of tweaking to handle an array of items. We have to store data in an ArrayCollection (line 2,5). At this point we could set up a renderer and a repeater to populate the form, but let&#8217;s have some fun with actionscript (lines 8-31).</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
</pre></td><td class="code"><pre class="actionscript" style="font-family:monospace;"><span style="color: #0066CC;">private</span> const <span style="color: #0066CC;">HEIGHT</span>:<span style="color: #0066CC;">int</span> = <span style="color: #cc66cc;">20</span>;
<span style="color: #0066CC;">private</span> <span style="color: #000000; font-weight: bold;">var</span> myItems:ArrayCollection;
&nbsp;
<span style="color: #0066CC;">private</span> <span style="color: #000000; font-weight: bold;">function</span> pasteFromClipboard<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>:<span style="color: #0066CC;">void</span> <span style="color: #66cc66;">&#123;</span>
	myItems = Clipboard.<span style="color: #006600;">generalClipboard</span>.<span style="color: #006600;">getData</span><span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">&quot;myCustomFormat&quot;</span><span style="color: #66cc66;">&#41;</span> 
		as ArrayCollection;
&nbsp;
	<span style="color: #b1b100;">for</span> <span style="color: #b1b100;">each</span> <span style="color: #66cc66;">&#40;</span><span style="color: #000000; font-weight: bold;">var</span> i <span style="color: #b1b100;">in</span> myItems<span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&#123;</span>
&nbsp;
		<span style="color: #000000; font-weight: bold;">var</span> nameLabel:FormItem = <span style="color: #000000; font-weight: bold;">new</span> FormItem<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>;
		nameLabel.<span style="color: #006600;">label</span> = <span style="color: #ff0000;">&quot;Name:&quot;</span>;
		<span style="color: #000000; font-weight: bold;">var</span> nameText:TextArea = <span style="color: #000000; font-weight: bold;">new</span> TextArea<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>;
		nameText.<span style="color: #0066CC;">height</span> = <span style="color: #0066CC;">HEIGHT</span>;
		nameText.<span style="color: #0066CC;">text</span> = i.<span style="color: #0066CC;">name</span>;
&nbsp;
		<span style="color: #000000; font-weight: bold;">var</span> emailLabel:FormItem = <span style="color: #000000; font-weight: bold;">new</span> FormItem<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>;
		emailLabel.<span style="color: #006600;">label</span> = <span style="color: #ff0000;">&quot;Email&quot;</span>;
		<span style="color: #000000; font-weight: bold;">var</span> emailText:TextArea = <span style="color: #000000; font-weight: bold;">new</span> TextArea<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>;
		emailText.<span style="color: #0066CC;">height</span> = <span style="color: #0066CC;">HEIGHT</span>;
		emailText.<span style="color: #0066CC;">text</span> = i.<span style="color: #006600;">email</span>;
&nbsp;
		nameLabel.<span style="color: #006600;">addChild</span><span style="color: #66cc66;">&#40;</span>nameText<span style="color: #66cc66;">&#41;</span>;
		emailLabel.<span style="color: #006600;">addChild</span><span style="color: #66cc66;">&#40;</span>emailText<span style="color: #66cc66;">&#41;</span>;
&nbsp;
		pastedItems.<span style="color: #006600;">addChild</span><span style="color: #66cc66;">&#40;</span>nameLabel<span style="color: #66cc66;">&#41;</span>;
		pastedItems.<span style="color: #006600;">addChild</span><span style="color: #66cc66;">&#40;</span>emailLabel<span style="color: #66cc66;">&#41;</span>;
&nbsp;
		<span style="color: #000000; font-weight: bold;">var</span> hr:HRule = <span style="color: #000000; font-weight: bold;">new</span> HRule<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>;
		hr.<span style="color: #0066CC;">width</span> = <span style="color: #cc66cc;">40</span>;
		pastedItems.<span style="color: #006600;">addChild</span><span style="color: #66cc66;">&#40;</span>hr<span style="color: #66cc66;">&#41;</span>;
	<span style="color: #66cc66;">&#125;</span>
<span style="color: #66cc66;">&#125;</span></pre></td></tr></table></div>

<p>Here is an example of the final result.</p>
<p><object classid='clsid:d27cdb6e-ae6d-11cf-96b8-444553540000' codebase='http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=9,0,115,0' width='560' height='345'><param name='movie' value='http://screenr.com/Content/assets/screenr_1116090935.swf' /><param name='flashvars' value='i=42503' /><param name='allowFullScreen' value='true' /><embed src='http://screenr.com/Content/assets/screenr_1116090935.swf' flashvars='i=42503' allowFullScreen='true' width='560' height='345' pluginspage='http://www.macromedia.com/go/getflashplayer'></embed></object></p>
<p><a href='http://spreadingfunkyness.com/wp-content/uploads/2010/01/ComplexMultiCopyPaste.zip'>Source code is available.</a></p>
]]></content:encoded>
			<wfw:commentRss>http://spreadingfunkyness.com/copy-and-paste-sets-of-complex-objects-in-adobe-air/feed/</wfw:commentRss>
		<slash:comments>11</slash:comments>
		</item>
		<item>
		<title>Copy and Paste a complex object in Adobe Air</title>
		<link>http://spreadingfunkyness.com/copy-and-paste-a-complex-object-in-adobe-air/</link>
		<comments>http://spreadingfunkyness.com/copy-and-paste-a-complex-object-in-adobe-air/#comments</comments>
		<pubDate>Wed, 27 Jan 2010 11:49:32 +0000</pubDate>
		<dc:creator>Cesare</dc:creator>
				<category><![CDATA[actionscript]]></category>
		<category><![CDATA[adobeair]]></category>
		<category><![CDATA[flex]]></category>
		<category><![CDATA[programming]]></category>

		<guid isPermaLink="false">http://spreadingfunkyness.com/?p=304</guid>
		<description><![CDATA[In Adobe Air you can store data in the object to enable cross application data transfer. We have already had a look at how to copy and paste images. In this tutorial we will see how to copy complex objects. By complex objects we mean a type of object which is not the usual String, ...]]></description>
			<content:encoded><![CDATA[<div class="tweetmeme_button" style="float: left; margin: 0px 10px 0px 0px;">
			<a href="http://api.tweetmeme.com/share?url=http%3A%2F%2Fspreadingfunkyness.com%2Fcopy-and-paste-a-complex-object-in-adobe-air%2F"><br />
				<img src="http://api.tweetmeme.com/imagebutton.gif?url=http%3A%2F%2Fspreadingfunkyness.com%2Fcopy-and-paste-a-complex-object-in-adobe-air%2F&amp;source=_funkyboy&amp;style=normal&amp;service=bit.ly&amp;b=2" height="61" width="50" /><br />
			</a>
		</div>
<p>In Adobe Air you can store data in the object to enable cross application data transfer. We have already had a look at <a href="http://spreadingfunkyness.com/copy-and-paste-images-in-adobe-air/">how to copy and paste images</a>. In this tutorial we will see how to copy complex objects. By complex objects we mean a type of object which is not the usual String, but something a bit more complicated, like an instance of Person.</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
12
</pre></td><td class="code"><pre class="actionscript" style="font-family:monospace;"><span style="color: #0066CC;">public</span> <span style="color: #000000; font-weight: bold;">class</span> Person <span style="color: #0066CC;">extends</span> <span style="color: #0066CC;">Object</span> <span style="color: #66cc66;">&#123;</span>
&nbsp;
	<span style="color: #0066CC;">public</span> <span style="color: #000000; font-weight: bold;">var</span> <span style="color: #0066CC;">name</span>:<span style="color: #0066CC;">String</span>;
	<span style="color: #0066CC;">public</span> <span style="color: #000000; font-weight: bold;">var</span> email:<span style="color: #0066CC;">String</span>;
&nbsp;
	<span style="color: #0066CC;">public</span> <span style="color: #000000; font-weight: bold;">function</span> Person<span style="color: #66cc66;">&#40;</span><span style="color: #0066CC;">name</span>:<span style="color: #0066CC;">String</span>, email:<span style="color: #0066CC;">String</span><span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&#123;</span>
		<span style="color: #0066CC;">super</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>;
		<span style="color: #0066CC;">this</span>.<span style="color: #0066CC;">name</span> = <span style="color: #0066CC;">name</span>;
		<span style="color: #0066CC;">this</span>.<span style="color: #006600;">email</span> = email;
	<span style="color: #66cc66;">&#125;</span>
&nbsp;
<span style="color: #66cc66;">&#125;</span></pre></td></tr></table></div>

<p>We will create two Adobe Air apps: the first is the source from which we copy data, the second is the destination where we paste data in the clipboard. Let&#8217;s start with the source application. We create some instance of Person to populate an ArrayCollection which we feed into a DataGrid.</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
</pre></td><td class="code"><pre class="actionscript" style="font-family:monospace;"><span style="color: #66cc66;">&lt;</span>mx:WindowedApplication 
	xmlns:mx=<span style="color: #ff0000;">&quot;http://www.adobe.com/2006/mxml&quot;</span> 
	layout=<span style="color: #ff0000;">&quot;vertical&quot;</span> 
	creationComplete=<span style="color: #ff0000;">&quot;init()&quot;</span><span style="color: #66cc66;">&gt;</span>
&nbsp;
	<span style="color: #66cc66;">&lt;</span>mx:Script<span style="color: #66cc66;">&gt;</span>
		<span style="color: #66cc66;">&lt;!</span><span style="color: #66cc66;">&#91;</span>CDATA<span style="color: #66cc66;">&#91;</span>
&nbsp;
		<span style="color: #0066CC;">import</span> mx.<span style="color: #006600;">collections</span>.<span style="color: #006600;">ArrayCollection</span>;
&nbsp;
		<span style="color: #66cc66;">&#91;</span>Bindable<span style="color: #66cc66;">&#93;</span> 
                <span style="color: #0066CC;">private</span> <span style="color: #000000; font-weight: bold;">var</span> collection:ArrayCollection = <span style="color: #000000; font-weight: bold;">new</span> ArrayCollection<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>
&nbsp;
		<span style="color: #0066CC;">private</span> <span style="color: #000000; font-weight: bold;">function</span> init<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>:<span style="color: #0066CC;">void</span> <span style="color: #66cc66;">&#123;</span>
			collection.<span style="color: #006600;">addItem</span><span style="color: #66cc66;">&#40;</span><span style="color: #000000; font-weight: bold;">new</span> Person<span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">&quot;John&quot;</span>, <span style="color: #ff0000;">&quot;john@john.com&quot;</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span>;
			collection.<span style="color: #006600;">addItem</span><span style="color: #66cc66;">&#40;</span><span style="color: #000000; font-weight: bold;">new</span> Person<span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">&quot;Mary&quot;</span>, <span style="color: #ff0000;">&quot;mary@mary.com&quot;</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span>;
		<span style="color: #66cc66;">&#125;</span>
&nbsp;
		<span style="color: #66cc66;">&#93;</span><span style="color: #66cc66;">&#93;</span><span style="color: #66cc66;">&gt;</span>
	<span style="color: #66cc66;">&lt;/</span>mx:Script<span style="color: #66cc66;">&gt;</span>
&nbsp;
	<span style="color: #66cc66;">&lt;</span>mx:DataGrid id=<span style="color: #ff0000;">&quot;grid&quot;</span> 
		dataProvider=<span style="color: #ff0000;">&quot;{collection}&quot;</span><span style="color: #66cc66;">&gt;</span>
&nbsp;
	<span style="color: #66cc66;">&lt;/</span>mx:DataGrid<span style="color: #66cc66;">&gt;</span>
&nbsp;
<span style="color: #66cc66;">&lt;/</span>mx:WindowedApplication<span style="color: #66cc66;">&gt;</span></pre></td></tr></table></div>

<p>We will add a button to trigger the copy action of the selected item. Then we need a way to detect the selected item in the grid and store it into the clipboard. We do this in the copyToClipboard function.</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
</pre></td><td class="code"><pre class="actionscript" style="font-family:monospace;"><span style="color: #0066CC;">private</span> <span style="color: #000000; font-weight: bold;">function</span> copyToClipboard<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>:<span style="color: #0066CC;">void</span> <span style="color: #66cc66;">&#123;</span>
&nbsp;
	<span style="color: #000000; font-weight: bold;">var</span> <span style="color: #0066CC;">selection</span>:Person = grid.<span style="color: #006600;">selectedItem</span> as Person;
	Clipboard.<span style="color: #006600;">generalClipboard</span>.<span style="color: #0066CC;">clear</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>;
	Clipboard.<span style="color: #006600;">generalClipboard</span>.<span style="color: #006600;">setData</span><span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">&quot;myCustomFormat&quot;</span>, <span style="color: #0066CC;">selection</span><span style="color: #66cc66;">&#41;</span>;
	feedback.<span style="color: #0066CC;">text</span> = <span style="color: #ff0000;">&quot;Data copied to the clipboard&quot;</span>;
&nbsp;
<span style="color: #66cc66;">&#125;</span></pre></td></tr></table></div>

<p>Here we should remember to be consistent with the key, <code>myCustomFormat</code>, that we adopt to store data in the clipboard (line 5). We&#8217;ll use the same key when we want to retrieve data in the Destination application. Below is the complete code of the Source application.</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
</pre></td><td class="code"><pre class="actionscript" style="font-family:monospace;"><span style="color: #66cc66;">&lt;</span>?<span style="color: #0066CC;">xml</span> <span style="color: #0066CC;">version</span>=<span style="color: #ff0000;">&quot;1.0&quot;</span> encoding=<span style="color: #ff0000;">&quot;utf-8&quot;</span>?<span style="color: #66cc66;">&gt;</span>
<span style="color: #66cc66;">&lt;</span>mx:WindowedApplication 
	xmlns:mx=<span style="color: #ff0000;">&quot;http://www.adobe.com/2006/mxml&quot;</span> 
	layout=<span style="color: #ff0000;">&quot;vertical&quot;</span> 
	creationComplete=<span style="color: #ff0000;">&quot;init()&quot;</span><span style="color: #66cc66;">&gt;</span>
&nbsp;
	<span style="color: #66cc66;">&lt;</span>mx:Script<span style="color: #66cc66;">&gt;</span>
	<span style="color: #66cc66;">&lt;!</span><span style="color: #66cc66;">&#91;</span>CDATA<span style="color: #66cc66;">&#91;</span>
	<span style="color: #0066CC;">import</span> mx.<span style="color: #006600;">collections</span>.<span style="color: #006600;">ArrayCollection</span>;
&nbsp;
	<span style="color: #66cc66;">&#91;</span>Bindable<span style="color: #66cc66;">&#93;</span> 
	<span style="color: #0066CC;">private</span> <span style="color: #000000; font-weight: bold;">var</span> collection:ArrayCollection = <span style="color: #000000; font-weight: bold;">new</span> ArrayCollection<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>
&nbsp;
	<span style="color: #0066CC;">private</span> <span style="color: #000000; font-weight: bold;">function</span> init<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>:<span style="color: #0066CC;">void</span> <span style="color: #66cc66;">&#123;</span>
		collection.<span style="color: #006600;">addItem</span><span style="color: #66cc66;">&#40;</span><span style="color: #000000; font-weight: bold;">new</span> Person<span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">&quot;John&quot;</span>, <span style="color: #ff0000;">&quot;john@john.com&quot;</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span>;
		collection.<span style="color: #006600;">addItem</span><span style="color: #66cc66;">&#40;</span><span style="color: #000000; font-weight: bold;">new</span> Person<span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">&quot;Mary&quot;</span>, <span style="color: #ff0000;">&quot;mary@mary.com&quot;</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span>;
	<span style="color: #66cc66;">&#125;</span>
&nbsp;
	<span style="color: #0066CC;">private</span> <span style="color: #000000; font-weight: bold;">function</span> copyToClipboard<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>:<span style="color: #0066CC;">void</span> <span style="color: #66cc66;">&#123;</span>
		<span style="color: #000000; font-weight: bold;">var</span> <span style="color: #0066CC;">selection</span>:Person = grid.<span style="color: #006600;">selectedItem</span> as Person;
		Clipboard.<span style="color: #006600;">generalClipboard</span>.<span style="color: #0066CC;">clear</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>;
		Clipboard.<span style="color: #006600;">generalClipboard</span>.<span style="color: #006600;">setData</span><span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">&quot;myCustomFormat&quot;</span>, <span style="color: #0066CC;">selection</span><span style="color: #66cc66;">&#41;</span>;
		feedback.<span style="color: #0066CC;">text</span> = <span style="color: #ff0000;">&quot;Data copied to the clipboard&quot;</span>;
	<span style="color: #66cc66;">&#125;</span>
	<span style="color: #66cc66;">&#93;</span><span style="color: #66cc66;">&#93;</span><span style="color: #66cc66;">&gt;</span>
	<span style="color: #66cc66;">&lt;/</span>mx:Script<span style="color: #66cc66;">&gt;</span>
&nbsp;
	<span style="color: #66cc66;">&lt;</span>mx:DataGrid id=<span style="color: #ff0000;">&quot;grid&quot;</span> 
		dataProvider=<span style="color: #ff0000;">&quot;{collection}&quot;</span><span style="color: #66cc66;">&gt;</span>
&nbsp;
	<span style="color: #66cc66;">&lt;/</span>mx:DataGrid<span style="color: #66cc66;">&gt;</span>
&nbsp;
	<span style="color: #66cc66;">&lt;</span>mx:<span style="color: #0066CC;">Button</span> label=<span style="color: #ff0000;">&quot;Copy to Clipboad&quot;</span> 
		<span style="color: #0066CC;">enabled</span>=<span style="color: #ff0000;">&quot;{grid.selectedItem != null}&quot;</span> 
		click=<span style="color: #ff0000;">&quot;copyToClipboard()&quot;</span><span style="color: #66cc66;">/&gt;</span>
&nbsp;
	<span style="color: #66cc66;">&lt;</span>mx:<span style="color: #0066CC;">Text</span> id=<span style="color: #ff0000;">&quot;feedback&quot;</span> <span style="color: #66cc66;">/&gt;</span>
&nbsp;
<span style="color: #66cc66;">&lt;/</span>mx:WindowedApplication<span style="color: #66cc66;">&gt;</span></pre></td></tr></table></div>

<p>Now let&#8217;s move to the Destination application, which we will have just a form and a button to paste data.</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
</pre></td><td class="code"><pre class="actionscript" style="font-family:monospace;"><span style="color: #66cc66;">&lt;</span>?<span style="color: #0066CC;">xml</span> <span style="color: #0066CC;">version</span>=<span style="color: #ff0000;">&quot;1.0&quot;</span> encoding=<span style="color: #ff0000;">&quot;utf-8&quot;</span>?<span style="color: #66cc66;">&gt;</span>
<span style="color: #66cc66;">&lt;</span>mx:WindowedApplication 
	xmlns:mx=<span style="color: #ff0000;">&quot;http://www.adobe.com/2006/mxml&quot;</span> 
	layout=<span style="color: #ff0000;">&quot;vertical&quot;</span><span style="color: #66cc66;">&gt;</span>
&nbsp;
	<span style="color: #66cc66;">&lt;</span>mx:Script<span style="color: #66cc66;">&gt;</span>
	<span style="color: #66cc66;">&lt;!</span><span style="color: #66cc66;">&#91;</span>CDATA<span style="color: #66cc66;">&#91;</span>
&nbsp;
	<span style="color: #66cc66;">&#91;</span>Bindable<span style="color: #66cc66;">&#93;</span> 
	<span style="color: #0066CC;">private</span> <span style="color: #000000; font-weight: bold;">var</span> myObj:<span style="color: #0066CC;">Object</span>;
&nbsp;
	<span style="color: #0066CC;">private</span> <span style="color: #000000; font-weight: bold;">function</span> pasteFromClipboard<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>:<span style="color: #0066CC;">void</span> <span style="color: #66cc66;">&#123;</span>
		myObj = Clipboard.<span style="color: #006600;">generalClipboard</span>.<span style="color: #006600;">getData</span><span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">&quot;myCustomFormat&quot;</span><span style="color: #66cc66;">&#41;</span>;
	<span style="color: #66cc66;">&#125;</span>
	<span style="color: #66cc66;">&#93;</span><span style="color: #66cc66;">&#93;</span><span style="color: #66cc66;">&gt;</span>
	<span style="color: #66cc66;">&lt;/</span>mx:Script<span style="color: #66cc66;">&gt;</span>
	<span style="color: #66cc66;">&lt;</span>mx:Form<span style="color: #66cc66;">&gt;</span>
		<span style="color: #66cc66;">&lt;</span>mx:FormItem label=<span style="color: #ff0000;">&quot;Name:&quot;</span><span style="color: #66cc66;">&gt;</span>
			<span style="color: #66cc66;">&lt;</span>mx:TextArea <span style="color: #0066CC;">text</span>=<span style="color: #ff0000;">&quot;{myObj.name}&quot;</span> <span style="color: #0066CC;">height</span>=<span style="color: #ff0000;">&quot;20&quot;</span><span style="color: #66cc66;">/&gt;</span>
		<span style="color: #66cc66;">&lt;/</span>mx:FormItem<span style="color: #66cc66;">&gt;</span>
		<span style="color: #66cc66;">&lt;</span>mx:FormItem label=<span style="color: #ff0000;">&quot;Email:&quot;</span><span style="color: #66cc66;">&gt;</span>
			<span style="color: #66cc66;">&lt;</span>mx:TextArea <span style="color: #0066CC;">text</span>=<span style="color: #ff0000;">&quot;{myObj.email}&quot;</span> <span style="color: #0066CC;">height</span>=<span style="color: #ff0000;">&quot;20&quot;</span><span style="color: #66cc66;">/&gt;</span>
		<span style="color: #66cc66;">&lt;/</span>mx:FormItem<span style="color: #66cc66;">&gt;</span>
	<span style="color: #66cc66;">&lt;/</span>mx:Form<span style="color: #66cc66;">&gt;</span>
&nbsp;
	<span style="color: #66cc66;">&lt;</span>mx:<span style="color: #0066CC;">Button</span> label=<span style="color: #ff0000;">&quot;Paste&quot;</span> click=<span style="color: #ff0000;">&quot;pasteFromClipboard()&quot;</span><span style="color: #66cc66;">/&gt;</span>
<span style="color: #66cc66;">&lt;/</span>mx:WindowedApplication<span style="color: #66cc66;">&gt;</span></pre></td></tr></table></div>

<p>As said above, to retrieve data in the clipboard we have to use the same key, <code>myCustomFormat</code>. The binding does the rest, populating our form. Here is a video of the result.</p>
<p><object classid='clsid:d27cdb6e-ae6d-11cf-96b8-444553540000' codebase='http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=9,0,115,0' width='560' height='345'><param name='movie' value='http://screenr.com/Content/assets/screenr_1116090935.swf' /><param name='flashvars' value='i=41246' /><param name='allowFullScreen' value='true' /><embed src='http://screenr.com/Content/assets/screenr_1116090935.swf' flashvars='i=41246' allowFullScreen='true' width='560' height='345' pluginspage='http://www.macromedia.com/go/getflashplayer'></embed></object></p>
<p><a href='http://spreadingfunkyness.com/wp-content/uploads/2010/01/ComplexCopyPaste.zip'>Source code</a> is available.</p>
<p><a class="a2a_dd a2a_target addtoany_share_save" href="http://www.addtoany.com/share_save#url=http%3A%2F%2Fspreadingfunkyness.com%2Fcopy-and-paste-a-complex-object-in-adobe-air%2F&amp;title=Copy%20and%20Paste%20a%20complex%20object%20in%20Adobe%20Air" id="wpa2a_6"><img src="http://spreadingfunkyness.com/wp-content/plugins/add-to-any/share_save_120_16.gif" width="120" height="16" alt="Share"/></a></p>]]></content:encoded>
			<wfw:commentRss>http://spreadingfunkyness.com/copy-and-paste-a-complex-object-in-adobe-air/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Copy and Paste Images in Adobe Air</title>
		<link>http://spreadingfunkyness.com/copy-and-paste-images-in-adobe-air/</link>
		<comments>http://spreadingfunkyness.com/copy-and-paste-images-in-adobe-air/#comments</comments>
		<pubDate>Fri, 22 Jan 2010 12:30:31 +0000</pubDate>
		<dc:creator>Cesare</dc:creator>
				<category><![CDATA[actionscript]]></category>
		<category><![CDATA[adobeair]]></category>
		<category><![CDATA[programming]]></category>

		<guid isPermaLink="false">http://spreadingfunkyness.com/?p=298</guid>
		<description><![CDATA[How to copy and paste images in Adobe Air.]]></description>
			<content:encoded><![CDATA[<div class="tweetmeme_button" style="float: left; margin: 0px 10px 0px 0px;">
			<a href="http://api.tweetmeme.com/share?url=http%3A%2F%2Fspreadingfunkyness.com%2Fcopy-and-paste-images-in-adobe-air%2F"><br />
				<img src="http://api.tweetmeme.com/imagebutton.gif?url=http%3A%2F%2Fspreadingfunkyness.com%2Fcopy-and-paste-images-in-adobe-air%2F&amp;source=_funkyboy&amp;style=normal&amp;service=bit.ly&amp;b=2" height="61" width="50" /><br />
			</a>
		</div>
<p>After learning <a href="http://spreadingfunkyness.com/drag-and-drop-of-images-in-adobe-air/">drag</a> and <a href="http://spreadingfunkyness.com/drag-and-drop-of-text-in-adobe-air/">drop</a> we will dig into copy and paste. We have <a href="http://spreadingfunkyness.com/native-drag-and-drop-in-adobe-air/">already seen</a> how to use the clipboard class to temporary store data during the drag action. Now we will use the same class to copy and paste an image within an Adobe Air application. We will start with the following layout.</p>
<p><a href="http://spreadingfunkyness.com/wp-content/uploads/2010/01/layout.gif"><img src="http://spreadingfunkyness.com/wp-content/uploads/2010/01/layout.gif" alt="" title="Layout of the application" width="500" height="397" class="aligncenter size-full wp-image-299" align="center" /></a></p>
<p>This corresponds to the following mxml code.</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
</pre></td><td class="code"><pre class="actionscript" style="font-family:monospace;"><span style="color: #66cc66;">&lt;</span>mx:WindowedApplication 
	xmlns:mx=<span style="color: #ff0000;">&quot;http://www.adobe.com/2006/mxml&quot;</span> 
	<span style="color: #0066CC;">backgroundColor</span>=<span style="color: #ff0000;">&quot;#222222&quot;</span> <span style="color: #0066CC;">color</span>=<span style="color: #ff0000;">&quot;#f5f5f5&quot;</span> 
	layout=<span style="color: #ff0000;">&quot;vertical&quot;</span><span style="color: #66cc66;">&gt;</span>
&nbsp;
	<span style="color: #66cc66;">&lt;!</span>-- Feedback --<span style="color: #66cc66;">&gt;</span>
	<span style="color: #66cc66;">&lt;</span>mx:<span style="color: #0066CC;">Text</span> id=<span style="color: #ff0000;">&quot;feedback&quot;</span> <span style="color: #0066CC;">height</span>=<span style="color: #ff0000;">&quot;20&quot;</span><span style="color: #66cc66;">/&gt;</span>
&nbsp;
	<span style="color: #66cc66;">&lt;!</span>-- Image to <span style="color: #0066CC;">copy</span> --<span style="color: #66cc66;">&gt;</span>
	<span style="color: #66cc66;">&lt;</span>mx:Image id=<span style="color: #ff0000;">&quot;im&quot;</span> source=<span style="color: #ff0000;">&quot;logo.png&quot;</span><span style="color: #66cc66;">/&gt;</span>
&nbsp;
	<span style="color: #66cc66;">&lt;!</span>-- Commands --<span style="color: #66cc66;">&gt;</span>
	<span style="color: #66cc66;">&lt;</span>mx:HBox<span style="color: #66cc66;">&gt;</span>
	    <span style="color: #66cc66;">&lt;</span>mx:<span style="color: #0066CC;">Button</span> label=<span style="color: #ff0000;">&quot;copy&quot;</span> 
	 	click=<span style="color: #ff0000;">&quot;copyToClipboard()&quot;</span><span style="color: #66cc66;">/&gt;</span>
	    <span style="color: #66cc66;">&lt;</span>mx:<span style="color: #0066CC;">Button</span> label=<span style="color: #ff0000;">&quot;paste&quot;</span> 
		click=<span style="color: #ff0000;">&quot;pasteFromClipboard()&quot;</span><span style="color: #66cc66;">/&gt;</span>	
	    <span style="color: #66cc66;">&lt;</span>mx:<span style="color: #0066CC;">Button</span> label=<span style="color: #ff0000;">&quot;clear&quot;</span> 
		click=<span style="color: #ff0000;">&quot;Clipboard.generalClipboard.clearData(ClipboardFormats.BITMAP_FORMAT)&quot;</span><span style="color: #66cc66;">/&gt;</span>
	<span style="color: #66cc66;">&lt;/</span>mx:HBox<span style="color: #66cc66;">&gt;</span>
&nbsp;
	<span style="color: #66cc66;">&lt;</span>mx:VBox id=<span style="color: #ff0000;">&quot;copies&quot;</span> <span style="color: #0066CC;">width</span>=<span style="color: #ff0000;">&quot;{im.width}&quot;</span><span style="color: #66cc66;">/&gt;</span>
<span style="color: #66cc66;">&lt;/</span>mx:WindowedApplication<span style="color: #66cc66;">&gt;</span></pre></td></tr></table></div>

<p>Let&#8217;s have a look at the copy mechanism. We want to be sure that, before copying, the clipboard has no bitmap (line 3). Then we create a BitmapData object to store the content of the image (lines 4-5) and we put it in the clipboard (line 6). We gently provide some feedback (line 7).</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
</pre></td><td class="code"><pre class="actionscript" style="font-family:monospace;"><span style="color: #0066CC;">private</span> <span style="color: #000000; font-weight: bold;">function</span> copyToClipboard<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>:<span style="color: #0066CC;">void</span> <span style="color: #66cc66;">&#123;</span>
&nbsp;
    Clipboard.<span style="color: #006600;">generalClipboard</span>.<span style="color: #006600;">clearData</span><span style="color: #66cc66;">&#40;</span>ClipboardFormats.<span style="color: #006600;">BITMAP_FORMAT</span><span style="color: #66cc66;">&#41;</span>;
    <span style="color: #000000; font-weight: bold;">var</span> <span style="color: #0066CC;">data</span>:BitmapData = <span style="color: #000000; font-weight: bold;">new</span> BitmapData<span style="color: #66cc66;">&#40;</span>im.<span style="color: #0066CC;">width</span>, im.<span style="color: #0066CC;">height</span><span style="color: #66cc66;">&#41;</span>;
    <span style="color: #0066CC;">data</span>.<span style="color: #006600;">draw</span><span style="color: #66cc66;">&#40;</span>im<span style="color: #66cc66;">&#41;</span>; <span style="color: #808080; font-style: italic;">// this copies the content in the clipboard</span>
    Clipboard.<span style="color: #006600;">generalClipboard</span>.<span style="color: #006600;">setData</span><span style="color: #66cc66;">&#40;</span>ClipboardFormats.<span style="color: #006600;">BITMAP_FORMAT</span>, <span style="color: #0066CC;">data</span><span style="color: #66cc66;">&#41;</span>;
    feedback.<span style="color: #0066CC;">text</span> = <span style="color: #ff0000;">&quot;Data have been copied&quot;</span>;
&nbsp;
<span style="color: #66cc66;">&#125;</span></pre></td></tr></table></div>

<p>The paste mechanism is pretty similar to the one illustrated in <a href="http://spreadingfunkyness.com/drag-and-drop-of-text-in-adobe-air/">previous tutorials</a>.  We read data from the clipboard (line 3), create a new Image class to store the Bitmap and then add it to the duplicates area (lines 4-7).</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
</pre></td><td class="code"><pre class="actionscript" style="font-family:monospace;"><span style="color: #0066CC;">private</span> <span style="color: #000000; font-weight: bold;">function</span> pasteFromClipboard<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>:<span style="color: #0066CC;">void</span> <span style="color: #66cc66;">&#123;</span>
&nbsp;
    <span style="color: #000000; font-weight: bold;">var</span> b:Bitmap = <span style="color: #000000; font-weight: bold;">new</span> Bitmap<span style="color: #66cc66;">&#40;</span>Clipboard.<span style="color: #006600;">generalClipboard</span>.<span style="color: #006600;">getData</span><span style="color: #66cc66;">&#40;</span>ClipboardFormats.<span style="color: #006600;">BITMAP_FORMAT</span><span style="color: #66cc66;">&#41;</span> as BitmapData<span style="color: #66cc66;">&#41;</span>;
    <span style="color: #000000; font-weight: bold;">var</span> i:Image = <span style="color: #000000; font-weight: bold;">new</span> Image<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>;
    i.<span style="color: #0066CC;">height</span> = b.<span style="color: #0066CC;">height</span>;
    i.<span style="color: #006600;">addChild</span><span style="color: #66cc66;">&#40;</span>b<span style="color: #66cc66;">&#41;</span>;
    copies.<span style="color: #006600;">addChild</span><span style="color: #66cc66;">&#40;</span>i<span style="color: #66cc66;">&#41;</span>;
&nbsp;
<span style="color: #66cc66;">&#125;</span></pre></td></tr></table></div>

<p>This is the intended result.</p>
<p><object classid='clsid:d27cdb6e-ae6d-11cf-96b8-444553540000' codebase='http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=9,0,115,0' width='560' height='345'><param name='movie' value='http://screenr.com/Content/assets/screenr_1116090935.swf' /><param name='flashvars' value='i=40450' /><param name='allowFullScreen' value='true' /><embed src='http://screenr.com/Content/assets/screenr_1116090935.swf' flashvars='i=40450' allowFullScreen='true' width='560' height='345' pluginspage='http://www.macromedia.com/go/getflashplayer'></embed></object></p>
<p><a href='http://spreadingfunkyness.com/wp-content/uploads/2010/01/ImageCopyAndPaste.zip'>Source code</a>  is available.<br />
Next time we will see how to copy and paste a complex object.</p>
]]></content:encoded>
			<wfw:commentRss>http://spreadingfunkyness.com/copy-and-paste-images-in-adobe-air/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Drag and Drop of Images In Adobe Air</title>
		<link>http://spreadingfunkyness.com/drag-and-drop-of-images-in-adobe-air/</link>
		<comments>http://spreadingfunkyness.com/drag-and-drop-of-images-in-adobe-air/#comments</comments>
		<pubDate>Tue, 19 Jan 2010 12:04:36 +0000</pubDate>
		<dc:creator>Cesare</dc:creator>
				<category><![CDATA[adobeair]]></category>
		<category><![CDATA[programming]]></category>

		<guid isPermaLink="false">http://spreadingfunkyness.com/?p=296</guid>
		<description><![CDATA[In this tutorial we will see how to show images dragged from the file system into an Adobe Air application. As we have seen in other tutorials to intercept when something is dragged and dropped on an Adobe Air application we need to specify two handlers: nativeDragEnter and nativeDragDrop. To accept the drag&#038;drop the content ...]]></description>
			<content:encoded><![CDATA[<div class="tweetmeme_button" style="float: left; margin: 0px 10px 0px 0px;">
			<a href="http://api.tweetmeme.com/share?url=http%3A%2F%2Fspreadingfunkyness.com%2Fdrag-and-drop-of-images-in-adobe-air%2F"><br />
				<img src="http://api.tweetmeme.com/imagebutton.gif?url=http%3A%2F%2Fspreadingfunkyness.com%2Fdrag-and-drop-of-images-in-adobe-air%2F&amp;source=_funkyboy&amp;style=normal&amp;service=bit.ly&amp;b=2" height="61" width="50" /><br />
			</a>
		</div>
<p>In this tutorial we will see how to show images dragged from the file system into an Adobe Air application. As we have seen in <a href="http://spreadingfunkyness.com/drag-and-drop-of-text-in-adobe-air/">other</a> <a href="http://spreadingfunkyness.com/native-drag-and-drop-in-adobe-air/">tutorials</a> to intercept when something is dragged and dropped on an Adobe Air application we need to specify two handlers: <code>nativeDragEnter</code> and <code>nativeDragDrop</code>. To accept the drag&#038;drop the content of the clipboard has to be a list of files (line 12). When there is a drop we store the content in an array (line 18). For each element of the array we check the extension (png in our case) and we create an image object, which we add to a tile list (lines 20-26).</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
</pre></td><td class="code"><pre class="actionscript" style="font-family:monospace;"><span style="color: #66cc66;">&lt;</span>mx:WindowedApplication xmlns:mx=<span style="color: #ff0000;">&quot;http://www.adobe.com/2006/mxml&quot;</span> 
    layout=<span style="color: #ff0000;">&quot;vertical&quot;</span> 
    nativeDragEnter=<span style="color: #ff0000;">&quot;dragEnterHandler(event)&quot;</span> 
    nativeDragDrop=<span style="color: #ff0000;">&quot;dropHandler(event)&quot;</span><span style="color: #66cc66;">&gt;</span>
&nbsp;
    <span style="color: #66cc66;">&lt;</span>mx:Script<span style="color: #66cc66;">&gt;</span>
	<span style="color: #66cc66;">&lt;!</span><span style="color: #66cc66;">&#91;</span>CDATA<span style="color: #66cc66;">&#91;</span>
&nbsp;
        <span style="color: #0066CC;">import</span> mx.<span style="color: #006600;">controls</span>.<span style="color: #006600;">Image</span>;
&nbsp;
	<span style="color: #0066CC;">private</span> <span style="color: #000000; font-weight: bold;">function</span> dragEnterHandler<span style="color: #66cc66;">&#40;</span><span style="color: #0066CC;">e</span>:NativeDragEvent<span style="color: #66cc66;">&#41;</span>:<span style="color: #0066CC;">void</span> <span style="color: #66cc66;">&#123;</span>
	    <span style="color: #b1b100;">if</span> <span style="color: #66cc66;">&#40;</span><span style="color: #0066CC;">e</span>.<span style="color: #006600;">clipboard</span>.<span style="color: #006600;">hasFormat</span><span style="color: #66cc66;">&#40;</span>ClipboardFormats.<span style="color: #006600;">FILE_LIST_FORMAT</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&#123;</span>
		NativeDragManager.<span style="color: #006600;">acceptDragDrop</span><span style="color: #66cc66;">&#40;</span><span style="color: #0066CC;">this</span><span style="color: #66cc66;">&#41;</span>;
	    <span style="color: #66cc66;">&#125;</span>
	<span style="color: #66cc66;">&#125;</span>
&nbsp;
	<span style="color: #0066CC;">private</span> <span style="color: #000000; font-weight: bold;">function</span> dropHandler<span style="color: #66cc66;">&#40;</span><span style="color: #0066CC;">e</span>:NativeDragEvent<span style="color: #66cc66;">&#41;</span>:<span style="color: #0066CC;">void</span> <span style="color: #66cc66;">&#123;</span>
	    <span style="color: #000000; font-weight: bold;">var</span> files:<span style="color: #0066CC;">Array</span> = <span style="color: #0066CC;">e</span>.<span style="color: #006600;">clipboard</span>.<span style="color: #006600;">getData</span><span style="color: #66cc66;">&#40;</span>ClipboardFormats.<span style="color: #006600;">FILE_LIST_FORMAT</span><span style="color: #66cc66;">&#41;</span> as <span style="color: #0066CC;">Array</span>;
&nbsp;
	    <span style="color: #b1b100;">for</span> <span style="color: #b1b100;">each</span> <span style="color: #66cc66;">&#40;</span><span style="color: #000000; font-weight: bold;">var</span> f:<span style="color: #0066CC;">Object</span> <span style="color: #b1b100;">in</span> files<span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&#123;</span>
	  	<span style="color: #b1b100;">if</span> <span style="color: #66cc66;">&#40;</span>f.<span style="color: #006600;">extension</span> == <span style="color: #ff0000;">&quot;png&quot;</span><span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&#123;</span>
		    <span style="color: #000000; font-weight: bold;">var</span> image:Image = <span style="color: #000000; font-weight: bold;">new</span> Image<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>;
		    image.<span style="color: #006600;">source</span> = <span style="color: #ff0000;">&quot;file:///&quot;</span> + f.<span style="color: #006600;">nativePath</span>
		    droppedImages.<span style="color: #006600;">addChild</span><span style="color: #66cc66;">&#40;</span>image<span style="color: #66cc66;">&#41;</span>;
		<span style="color: #66cc66;">&#125;</span>
	    <span style="color: #66cc66;">&#125;</span>
	<span style="color: #66cc66;">&#125;</span>
	<span style="color: #66cc66;">&#93;</span><span style="color: #66cc66;">&#93;</span><span style="color: #66cc66;">&gt;</span>
    <span style="color: #66cc66;">&lt;/</span>mx:Script<span style="color: #66cc66;">&gt;</span>
&nbsp;
    <span style="color: #66cc66;">&lt;</span>mx:Tile id=<span style="color: #ff0000;">&quot;droppedImages&quot;</span> <span style="color: #66cc66;">/&gt;</span>
<span style="color: #66cc66;">&lt;/</span>mx:WindowedApplication<span style="color: #66cc66;">&gt;</span></pre></td></tr></table></div>

<p>The result should look something like this video.</p>
<p><object classid='clsid:d27cdb6e-ae6d-11cf-96b8-444553540000' codebase='http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=9,0,115,0' width='560' height='345'><param name='movie' value='http://screenr.com/Content/assets/screenr_1116090935.swf' /><param name='flashvars' value='i=39801' /><param name='allowFullScreen' value='true' /><embed src='http://screenr.com/Content/assets/screenr_1116090935.swf' flashvars='i=39801' allowFullScreen='true' width='560' height='345' pluginspage='http://www.macromedia.com/go/getflashplayer'></embed></object></p>
<p><a href='http://spreadingfunkyness.com/wp-content/uploads/2010/01/NativeImageDragAndDrop.zip'>Source code</a> is available.</p>
<p><a class="a2a_dd a2a_target addtoany_share_save" href="http://www.addtoany.com/share_save#url=http%3A%2F%2Fspreadingfunkyness.com%2Fdrag-and-drop-of-images-in-adobe-air%2F&amp;title=Drag%20and%20Drop%20of%20Images%20In%20Adobe%20Air" id="wpa2a_8"><img src="http://spreadingfunkyness.com/wp-content/plugins/add-to-any/share_save_120_16.gif" width="120" height="16" alt="Share"/></a></p>]]></content:encoded>
			<wfw:commentRss>http://spreadingfunkyness.com/drag-and-drop-of-images-in-adobe-air/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Drag and Drop of Text in Adobe Air</title>
		<link>http://spreadingfunkyness.com/drag-and-drop-of-text-in-adobe-air/</link>
		<comments>http://spreadingfunkyness.com/drag-and-drop-of-text-in-adobe-air/#comments</comments>
		<pubDate>Sat, 16 Jan 2010 13:42:05 +0000</pubDate>
		<dc:creator>Cesare</dc:creator>
				<category><![CDATA[adobeair]]></category>
		<category><![CDATA[programming]]></category>

		<guid isPermaLink="false">http://spreadingfunkyness.com/?p=294</guid>
		<description><![CDATA[In a previous tutorial we have seen how to drag and drop images from a native application (Fireworks) to Adobe Air and between two air apps. In this post I will show how to drag and drop text from a document (pdf, html, txt) into a text area of an Adobe Air application. Our application ...]]></description>
			<content:encoded><![CDATA[<div class="tweetmeme_button" style="float: left; margin: 0px 10px 0px 0px;">
			<a href="http://api.tweetmeme.com/share?url=http%3A%2F%2Fspreadingfunkyness.com%2Fdrag-and-drop-of-text-in-adobe-air%2F"><br />
				<img src="http://api.tweetmeme.com/imagebutton.gif?url=http%3A%2F%2Fspreadingfunkyness.com%2Fdrag-and-drop-of-text-in-adobe-air%2F&amp;source=_funkyboy&amp;style=normal&amp;service=bit.ly&amp;b=2" height="61" width="50" /><br />
			</a>
		</div>
<p>In a <a href="http://spreadingfunkyness.com/native-drag-and-drop-in-adobe-air/">previous tutorial</a> we have seen how to drag and drop images from a native application (Fireworks) to Adobe Air and between two air apps. In this post I will show how to drag and drop text from a document (pdf, html, txt) into a text area of an Adobe Air application.<br />
Our application has to specify two handlers: <code>nativeDragEnter</code> and <code>nativeDragDrop</code> (lines 3-4). In the first we will check whether the content in the clipboard is textual (lines 11-12), in the second we will dump the content in a Text component (line 17).</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
</pre></td><td class="code"><pre class="actionscript" style="font-family:monospace;"><span style="color: #66cc66;">&lt;</span>mx:WindowedApplication xmlns:mx=<span style="color: #ff0000;">&quot;http://www.adobe.com/2006/mxml&quot;</span> 
    layout=<span style="color: #ff0000;">&quot;vertical&quot;</span> 
    nativeDragEnter=<span style="color: #ff0000;">&quot;dragEnterHandler(event)&quot;</span> 
    nativeDragDrop=<span style="color: #ff0000;">&quot;dropHandler(event)&quot;</span><span style="color: #66cc66;">&gt;</span>
&nbsp;
    <span style="color: #66cc66;">&lt;</span>mx:Script<span style="color: #66cc66;">&gt;</span>
	<span style="color: #66cc66;">&lt;!</span><span style="color: #66cc66;">&#91;</span>CDATA<span style="color: #66cc66;">&#91;</span>
&nbsp;
	<span style="color: #0066CC;">private</span> <span style="color: #000000; font-weight: bold;">function</span> dragEnterHandler<span style="color: #66cc66;">&#40;</span><span style="color: #0066CC;">e</span>:NativeDragEvent<span style="color: #66cc66;">&#41;</span>:<span style="color: #0066CC;">void</span> <span style="color: #66cc66;">&#123;</span>
	    <span style="color: #808080; font-style: italic;">// check whether content is textual</span>
	    <span style="color: #b1b100;">if</span> <span style="color: #66cc66;">&#40;</span><span style="color: #0066CC;">e</span>.<span style="color: #006600;">clipboard</span>.<span style="color: #006600;">hasFormat</span><span style="color: #66cc66;">&#40;</span>ClipboardFormats.<span style="color: #006600;">TEXT_FORMAT</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&#123;</span>
	 	NativeDragManager.<span style="color: #006600;">acceptDragDrop</span><span style="color: #66cc66;">&#40;</span><span style="color: #0066CC;">this</span><span style="color: #66cc66;">&#41;</span>;
	    <span style="color: #66cc66;">&#125;</span>
	<span style="color: #66cc66;">&#125;</span>
&nbsp;
	<span style="color: #0066CC;">private</span> <span style="color: #000000; font-weight: bold;">function</span> dropHandler<span style="color: #66cc66;">&#40;</span><span style="color: #0066CC;">e</span>:NativeDragEvent<span style="color: #66cc66;">&#41;</span>:<span style="color: #0066CC;">void</span> <span style="color: #66cc66;">&#123;</span>
	    droppedText.<span style="color: #0066CC;">text</span> = <span style="color: #0066CC;">e</span>.<span style="color: #006600;">clipboard</span>.<span style="color: #006600;">getData</span><span style="color: #66cc66;">&#40;</span>ClipboardFormats.<span style="color: #006600;">TEXT_FORMAT</span><span style="color: #66cc66;">&#41;</span> as <span style="color: #0066CC;">String</span>;
	<span style="color: #66cc66;">&#125;</span>
&nbsp;
	<span style="color: #66cc66;">&#93;</span><span style="color: #66cc66;">&#93;</span><span style="color: #66cc66;">&gt;</span>
    <span style="color: #66cc66;">&lt;/</span>mx:Script<span style="color: #66cc66;">&gt;</span>
&nbsp;
    <span style="color: #66cc66;">&lt;</span>mx:<span style="color: #0066CC;">Text</span> id=<span style="color: #ff0000;">&quot;droppedText&quot;</span> <span style="color: #0066CC;">width</span>=<span style="color: #ff0000;">&quot;100%&quot;</span><span style="color: #66cc66;">/&gt;</span>
<span style="color: #66cc66;">&lt;/</span>mx:WindowedApplication<span style="color: #66cc66;">&gt;</span></pre></td></tr></table></div>

<p>Let&#8217;s check whether it works!</p>
<p><object classid='clsid:d27cdb6e-ae6d-11cf-96b8-444553540000' codebase='http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=9,0,115,0' width='560' height='345'><param name='movie' value='http://screenr.com/Content/assets/screenr_1116090935.swf' /><param name='flashvars' value='i=39210' /><param name='allowFullScreen' value='true' /><embed src='http://screenr.com/Content/assets/screenr_1116090935.swf' flashvars='i=39210' allowFullScreen='true' width='560' height='345' pluginspage='http://www.macromedia.com/go/getflashplayer'></embed></object></p>
<p>Happy drag&#038;dropping :)<br />
<a href='http://spreadingfunkyness.com/wp-content/uploads/2010/01/NativeTextDragAndDrop.zip'>Source code</a> is available.<br />
In the next tutorial we will see how to drag and drop images from the file system.<br />
Stay tuned.</p>
<p><a class="a2a_dd a2a_target addtoany_share_save" href="http://www.addtoany.com/share_save#url=http%3A%2F%2Fspreadingfunkyness.com%2Fdrag-and-drop-of-text-in-adobe-air%2F&amp;title=Drag%20and%20Drop%20of%20Text%20in%20Adobe%20Air" id="wpa2a_10"><img src="http://spreadingfunkyness.com/wp-content/plugins/add-to-any/share_save_120_16.gif" width="120" height="16" alt="Share"/></a></p>]]></content:encoded>
			<wfw:commentRss>http://spreadingfunkyness.com/drag-and-drop-of-text-in-adobe-air/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Native Drag and Drop in Adobe Air</title>
		<link>http://spreadingfunkyness.com/native-drag-and-drop-in-adobe-air/</link>
		<comments>http://spreadingfunkyness.com/native-drag-and-drop-in-adobe-air/#comments</comments>
		<pubDate>Thu, 14 Jan 2010 12:06:37 +0000</pubDate>
		<dc:creator>Cesare</dc:creator>
				<category><![CDATA[adobeair]]></category>
		<category><![CDATA[programming]]></category>

		<guid isPermaLink="false">http://spreadingfunkyness.com/?p=292</guid>
		<description><![CDATA[In this tutorial we will learn the basics of native drag and drop in Adobe Air. Specifically we will see two examples: drag an image from a native application (Fireworks) and drop it onto an air application drag an image from an air application and drop it onto another air application We will start by ...]]></description>
			<content:encoded><![CDATA[<div class="tweetmeme_button" style="float: left; margin: 0px 10px 0px 0px;">
			<a href="http://api.tweetmeme.com/share?url=http%3A%2F%2Fspreadingfunkyness.com%2Fnative-drag-and-drop-in-adobe-air%2F"><br />
				<img src="http://api.tweetmeme.com/imagebutton.gif?url=http%3A%2F%2Fspreadingfunkyness.com%2Fnative-drag-and-drop-in-adobe-air%2F&amp;source=_funkyboy&amp;style=normal&amp;service=bit.ly&amp;b=2" height="61" width="50" /><br />
			</a>
		</div>
<p>In this tutorial we will learn the basics of native drag and drop in Adobe Air. Specifically we will see two examples:</p>
<ul>
<li>drag an image from a native application (Fireworks) and drop it onto an air application</li>
<li>drag an image from an air application and drop it onto another air application</li>
</ul>
<p>We will start by implementing the target application, which accepts the drop action. To enable this there are two behaviors to specify: what to do when something is dragged over the app and what to do when there is a drop action. These correspond to two events: nativeDragEnter and nativeDragDrop, both belonging to the WindowedApplication class. So we will start with this code.</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
7
</pre></td><td class="code"><pre class="actionscript" style="font-family:monospace;"><span style="color: #66cc66;">&lt;</span>mx:WindowedApplication 
        xmlns:mx=<span style="color: #ff0000;">&quot;http://www.adobe.com/2006/mxml&quot;</span> 
        layout=<span style="color: #ff0000;">&quot;absolute&quot;</span> 
	nativeDragEnter=<span style="color: #ff0000;">&quot;dragEnterHandler(event)&quot;</span> 
	nativeDragDrop=<span style="color: #ff0000;">&quot;dropHandler(event)&quot;</span><span style="color: #66cc66;">&gt;</span>
&nbsp;
<span style="color: #66cc66;">&lt;/</span>mx:WindowedApplication<span style="color: #66cc66;">&gt;</span></pre></td></tr></table></div>

<p>Once associated the handlers we need to define them.</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
</pre></td><td class="code"><pre class="actionscript" style="font-family:monospace;"><span style="color: #66cc66;">&lt;</span>mx:Script<span style="color: #66cc66;">&gt;</span>
	<span style="color: #66cc66;">&lt;!</span><span style="color: #66cc66;">&#91;</span>CDATA<span style="color: #66cc66;">&#91;</span>
&nbsp;
	<span style="color: #0066CC;">private</span> <span style="color: #000000; font-weight: bold;">function</span> dragEnterHandler<span style="color: #66cc66;">&#40;</span><span style="color: #0066CC;">e</span>:NativeDragEvent<span style="color: #66cc66;">&#41;</span>:<span style="color: #0066CC;">void</span> <span style="color: #66cc66;">&#123;</span>
		<span style="color: #b1b100;">if</span> <span style="color: #66cc66;">&#40;</span><span style="color: #0066CC;">e</span>.<span style="color: #006600;">clipboard</span>.<span style="color: #006600;">hasFormat</span><span style="color: #66cc66;">&#40;</span>ClipboardFormats.<span style="color: #006600;">BITMAP_FORMAT</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&#123;</span>
			NativeDragManager.<span style="color: #006600;">acceptDragDrop</span><span style="color: #66cc66;">&#40;</span><span style="color: #0066CC;">this</span><span style="color: #66cc66;">&#41;</span>;
		<span style="color: #66cc66;">&#125;</span>
	<span style="color: #66cc66;">&#125;</span>
&nbsp;
	<span style="color: #0066CC;">private</span> <span style="color: #000000; font-weight: bold;">function</span> dropHandler<span style="color: #66cc66;">&#40;</span><span style="color: #0066CC;">e</span>:NativeDragEvent<span style="color: #66cc66;">&#41;</span>:<span style="color: #0066CC;">void</span> <span style="color: #66cc66;">&#123;</span>
		<span style="color: #000000; font-weight: bold;">var</span> <span style="color: #0066CC;">data</span>:BitmapData = <span style="color: #0066CC;">e</span>.<span style="color: #006600;">clipboard</span>.<span style="color: #006600;">getData</span><span style="color: #66cc66;">&#40;</span>ClipboardFormats.<span style="color: #006600;">BITMAP_FORMAT</span><span style="color: #66cc66;">&#41;</span> as BitmapData;
		<span style="color: #000000; font-weight: bold;">var</span> myBit:Bitmap = <span style="color: #000000; font-weight: bold;">new</span> Bitmap<span style="color: #66cc66;">&#40;</span><span style="color: #0066CC;">data</span><span style="color: #66cc66;">&#41;</span>;
		<span style="color: #0066CC;">stage</span>.<span style="color: #006600;">addChild</span><span style="color: #66cc66;">&#40;</span>myBit<span style="color: #66cc66;">&#41;</span>;
	<span style="color: #66cc66;">&#125;</span>
&nbsp;
      <span style="color: #66cc66;">&#93;</span><span style="color: #66cc66;">&#93;</span><span style="color: #66cc66;">&gt;</span>
<span style="color: #66cc66;">&lt;/</span>mx:Script<span style="color: #66cc66;">&gt;</span></pre></td></tr></table></div>

<p>In the nativeDragEnter event we have to check whether the dragged item is of type bitmap, if yes we can accept the drag (lines 29-30). During the drag a copy of the item is stored in the system&#8217;s clipboard. To replicate it in the target application we have to read it (line 35), clone it (line 36) and then add it to the display tree (line 37). This is all we need to do in the target application. At this point we can already test the application. Let&#8217;s run it, open an image in Fireworks and drag&#038;drop it. See the video below.</p>
<p><object classid='clsid:d27cdb6e-ae6d-11cf-96b8-444553540000' codebase='http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=9,0,115,0' width='560' height='345'><param name='movie' value='http://screenr.com/Content/assets/screenr_1116090935.swf' ></param><param name='flashvars' value='i=38951' ></param><param name='allowFullScreen' value='true' ></param><embed src='http://screenr.com/Content/assets/screenr_1116090935.swf' flashvars='i=38951' allowFullScreen='true' width='560' height='345' pluginspage='http://www.macromedia.com/go/getflashplayer' ></embed></object></p>
<p>Now let&#8217;s move to the other case: we start dragging an image from another air application. Here we have to mimic the behavior of Fireworks above: copy in the system clipboard the image when there is a startDrag action. Let&#8217;s start  by adding an image to the application.</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
</pre></td><td class="code"><pre class="actionscript" style="font-family:monospace;"><span style="color: #66cc66;">&lt;</span>mx:WindowedApplication 
	xmlns:mx=<span style="color: #ff0000;">&quot;http://www.adobe.com/2006/mxml&quot;</span> 
	layout=<span style="color: #ff0000;">&quot;absolute&quot;</span><span style="color: #66cc66;">&gt;</span>
&nbsp;
	<span style="color: #66cc66;">&lt;</span>mx:Image id=<span style="color: #ff0000;">&quot;image&quot;</span> 
		source=<span style="color: #ff0000;">&quot;logo.png&quot;</span> 
		mouseDown=<span style="color: #ff0000;">&quot;startDragDrop(event)&quot;</span><span style="color: #66cc66;">/&gt;</span> 
<span style="color: #66cc66;">&lt;/</span>mx:WindowedApplication<span style="color: #66cc66;">&gt;</span></pre></td></tr></table></div>

<p>As you can see we attached a function to the mouseDown event. Now let&#8217;s define this function.</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
</pre></td><td class="code"><pre class="actionscript" style="font-family:monospace;"><span style="color: #66cc66;">&lt;</span>mx:Script<span style="color: #66cc66;">&gt;</span>
	<span style="color: #66cc66;">&lt;!</span><span style="color: #66cc66;">&#91;</span>CDATA<span style="color: #66cc66;">&#91;</span>
&nbsp;
	<span style="color: #0066CC;">private</span> <span style="color: #000000; font-weight: bold;">function</span> startDragDrop<span style="color: #66cc66;">&#40;</span><span style="color: #0066CC;">e</span>:MouseEvent<span style="color: #66cc66;">&#41;</span>:<span style="color: #0066CC;">void</span> <span style="color: #66cc66;">&#123;</span>
&nbsp;
		<span style="color: #000000; font-weight: bold;">var</span> <span style="color: #0066CC;">data</span>:BitmapData = <span style="color: #000000; font-weight: bold;">new</span> BitmapData<span style="color: #66cc66;">&#40;</span>image.<span style="color: #0066CC;">width</span>, image.<span style="color: #0066CC;">height</span><span style="color: #66cc66;">&#41;</span>;
		<span style="color: #0066CC;">data</span>.<span style="color: #006600;">draw</span><span style="color: #66cc66;">&#40;</span>image<span style="color: #66cc66;">&#41;</span>;
&nbsp;
		<span style="color: #808080; font-style: italic;">// create my clipboard object to be passed to dragmanager</span>
		<span style="color: #000000; font-weight: bold;">var</span> cb:Clipboard = <span style="color: #000000; font-weight: bold;">new</span> Clipboard<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>;
		cb.<span style="color: #006600;">setData</span><span style="color: #66cc66;">&#40;</span>ClipboardFormats.<span style="color: #006600;">BITMAP_FORMAT</span>, <span style="color: #0066CC;">data</span><span style="color: #66cc66;">&#41;</span>;
&nbsp;
		<span style="color: #808080; font-style: italic;">// data here is a 'representative' of the dragged object during dragging.</span>
		NativeDragManager.<span style="color: #006600;">doDrag</span><span style="color: #66cc66;">&#40;</span><span style="color: #0066CC;">this</span>, cb, <span style="color: #0066CC;">data</span><span style="color: #66cc66;">&#41;</span>; 
&nbsp;
	<span style="color: #66cc66;">&#125;</span>
	<span style="color: #66cc66;">&#93;</span><span style="color: #66cc66;">&#93;</span><span style="color: #66cc66;">&gt;</span>
<span style="color: #66cc66;">&lt;/</span>mx:Script<span style="color: #66cc66;">&gt;</span></pre></td></tr></table></div>

<p>We create a copy of the image (lines 25-26). We use this in two cases: to put it in a clipboard object (line 30) and to provide feedback during the dragging (line 33). Now we can run both applications and check if everything is correct. </p>
<p><object classid='clsid:d27cdb6e-ae6d-11cf-96b8-444553540000' codebase='http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=9,0,115,0' width='560' height='345'><param name='movie' value='http://screenr.com/Content/assets/screenr_1116090935.swf' /><param name='flashvars' value='i=38956' /><param name='allowFullScreen' value='true' /><embed src='http://screenr.com/Content/assets/screenr_1116090935.swf' flashvars='i=38956' allowFullScreen='true' width='560' height='345' pluginspage='http://www.macromedia.com/go/getflashplayer'></embed></object></p>
<p>Simple uh? Please drop a comment if you have any followup question.<br />
<a href='http://spreadingfunkyness.com/wp-content/uploads/2010/01/NativeDragDrop.zip'>Source code</a> is available.</p>
<p><a class="a2a_dd a2a_target addtoany_share_save" href="http://www.addtoany.com/share_save#url=http%3A%2F%2Fspreadingfunkyness.com%2Fnative-drag-and-drop-in-adobe-air%2F&amp;title=Native%20Drag%20and%20Drop%20in%20Adobe%20Air" id="wpa2a_12"><img src="http://spreadingfunkyness.com/wp-content/plugins/add-to-any/share_save_120_16.gif" width="120" height="16" alt="Share"/></a></p>]]></content:encoded>
			<wfw:commentRss>http://spreadingfunkyness.com/native-drag-and-drop-in-adobe-air/feed/</wfw:commentRss>
		<slash:comments>9</slash:comments>
		</item>
		<item>
		<title>Code or not in your spare time? Does it really matter?</title>
		<link>http://spreadingfunkyness.com/code-or-not-in-your-spare-time/</link>
		<comments>http://spreadingfunkyness.com/code-or-not-in-your-spare-time/#comments</comments>
		<pubDate>Wed, 21 Oct 2009 13:50:19 +0000</pubDate>
		<dc:creator>Cesare</dc:creator>
				<category><![CDATA[productivity]]></category>
		<category><![CDATA[programming]]></category>

		<guid isPermaLink="false">http://spreadingfunkyness.com/?p=280</guid>
		<description><![CDATA[Code or not in your spare time? I think it doesn't matter. I show you pros and cons of both.]]></description>
			<content:encoded><![CDATA[<div class="tweetmeme_button" style="float: left; margin: 0px 10px 0px 0px;">
			<a href="http://api.tweetmeme.com/share?url=http%3A%2F%2Fspreadingfunkyness.com%2Fcode-or-not-in-your-spare-time%2F"><br />
				<img src="http://api.tweetmeme.com/imagebutton.gif?url=http%3A%2F%2Fspreadingfunkyness.com%2Fcode-or-not-in-your-spare-time%2F&amp;source=_funkyboy&amp;style=normal&amp;service=bit.ly&amp;b=2" height="61" width="50" /><br />
			</a>
		</div>
<p>There is some buzz around the topic &#8220;I prefer or not you to code in your spare time&#8221;. I guess it all started with <a href="http://teddziuba.com/2009/10/i-dont-code-in-my-free-time.html">Ted&#8217;s post</a>. I think it is just an excuse if somebody tells you: &#8220;we are not hiring you because you don&#8217;t program in your spare time&#8221;. I like both developing and designing <a href="http://spreadingfunkyness.com/posty/">personal</a> <a href="http://spreadingfunkyness.com/focused/">projects</a>. By definition personal projects don&#8217;t provide any income (at least at the beginning) so you end up working on them during the evening or the weekend. But &#8230; there are weekends I don&#8217;t want to see anything which has to do with technology. Will you hire me anyway? Will you like the part of me which refuses technology during Saturday and Sunday? More provocative: is it negative to the success of your project that I live 48 hours of my life avoiding technology and specifically computers?<br />
I will anticipate my final moral: you shouldn&#8217;t care, but let&#8217;s see why.</p>
<p>Let&#8217;s exaggerate by reversing the reasoning. I am a project manager and I say: &#8220;you absolutely have to code in your spare time, on some project of yours, otherwise I&#8217;ll not hire you&#8221;. How many people will file a cv in this case? Probably a few. The same holds for the opposite statement: &#8220;you absolutely have not to code in your spare time. Don&#8217;t touch any computer during the weekend&#8221;. More or less the result should be the same, few candidates. Why? Because you sort of <strong>invade privacy</strong>. There are many people around that don&#8217;t care of the job itself, it is just a means to get an income. If you want somebody committed to your project then prepare yourself to do many interviews and, moreover, you will discover the commitment only after one month (or more) you hired the programmer. You can be more lucky if you spread an inspiring call for job, with a few technical requirements and much more details about the motivation behind the project. Something like: &#8220;we are working on a project that will revolutionize the way people blog&#8221; can help you to be surrounded by people that share with you an objective.</p>
<p>In case you already have a project, somebody working on that, and you need someone&#8217;s help to not pass the deadline, <strong>don&#8217;t bother with their private life</strong>. Let&#8217;s say you need a php programmer to finalize part of a project. Let&#8217;s also pretend you find somebody so in love with php and technology which contributes to some open source project during his spare time. This can be be a <strong>double-edged</strong> sword. In the best case you are lucky, because the person you hire knows tips and tricks of php, many of which -probably &#8211; have been learnt during spare time programming. You hired a genius, and you are sure your project will be successful. Let me be evil.</p>
<ul>
<li>what if the genius gets involved in a toy project, more engaging than yours? </li>
<li>What if he starts working during the evening, maybe going to bed late? </li>
<li>Will his brain be fresh and ready for your project the day after?</li>
<li>Will his attention be the same of the day before?</li>
<li>More evil: what if he works on the open source project during the weekend? That&#8217;s what you want right? </li>
<li>What if on Monday he is a bit tired of staying in front of a monitor with a php editor open? </li>
<li>What if his spare time passion causes even a temporary indigestion?</li>
</ul>
<p>I think that you don&#8217;t want that.<br />
<strong>A spare time passion can feed or subtract energy</strong> to your project, whatever the passion is. If I go skying during the weekend and I arrive home sunday night, late, on monday I can be satisfied and ready to work as well as tired and not ready to code for your project. In the second case, will you ever tell me I should quit skying? Will your job post include a &#8220;no snow riders&#8221; restriction? I think no.<br />
Passion for &#8216;x&#8217; does not mean you do or you want to do &#8216;x&#8217; everyday. Also, passion for programming does not imply you code all day and night. It means you read and write books/posts about programming, subscribe to rss and podcasts, stay updated with news, look at someone&#8217;s code etc. EVERY developer does it, otherwise he is not a developer.  Just like ANY designer feeds his creativity by taking pictures or getting inspired by the nature. Just like ANYBODY chooses his on way to spend the weekend.<br />
Last provocation: in my life I met many developers and I noticed that many of them like to drink beer. Will you include that as a requirement when you post a job call? :)<br />
I think you should not focus your search on what a developer/designer does during his spare time. You should rather focus on professionalism and seriousness. <strong>If I do what you want, without passing the deadline, isn&#8217;t enough?</strong> </p>
]]></content:encoded>
			<wfw:commentRss>http://spreadingfunkyness.com/code-or-not-in-your-spare-time/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>The Iphone is a</title>
		<link>http://spreadingfunkyness.com/the-iphone-is-a/</link>
		<comments>http://spreadingfunkyness.com/the-iphone-is-a/#comments</comments>
		<pubDate>Mon, 21 Sep 2009 12:11:39 +0000</pubDate>
		<dc:creator>Cesare</dc:creator>
				<category><![CDATA[iphone]]></category>
		<category><![CDATA[productivity]]></category>
		<category><![CDATA[programming]]></category>

		<guid isPermaLink="false">http://spreadingfunkyness.com/?p=277</guid>
		<description><![CDATA[My reflections after 6 months of Iphone 3Gs]]></description>
			<content:encoded><![CDATA[<div class="tweetmeme_button" style="float: left; margin: 0px 10px 0px 0px;">
			<a href="http://api.tweetmeme.com/share?url=http%3A%2F%2Fspreadingfunkyness.com%2Fthe-iphone-is-a%2F"><br />
				<img src="http://api.tweetmeme.com/imagebutton.gif?url=http%3A%2F%2Fspreadingfunkyness.com%2Fthe-iphone-is-a%2F&amp;source=_funkyboy&amp;style=normal&amp;service=bit.ly&amp;b=2" height="61" width="50" /><br />
			</a>
		</div>
<p>After six months of iPhone these are my reflections, in the form of &#8220;The iPhone is a &#8230;&#8221;</p>
<h2>Time saver</h2>
<p>The only thing to complete your daily todo list is to wait for an email and redirect it to someonelse? Go to the beach, play volley and in the pause between one set and the other check the email and reply/redirect accordingly. </p>
<h2>Angryness preventer</h2>
<p>You have to go to pick your girlfriend up. You&#8217;d really like to check some more news or finish reading a blog post, but you agreed to be at her place at 9 pm. You are on time, she is late. With no iPhone you&#8217;d probably feel angry. Grab your iphone out of the pocket and finish checking news. Stumbled upon something interesting? Use <a href="http://readitlaterlist.com/iphone/">Read It Later</a>.</p>
<h2>Boredom preventer</h2>
<p>Bored to wait at the bus stop? Nobody to talk to and the bus is late? Open one of the tons of applications and play with it. Side effect: might loose the bus.</p>
<h2>Good guide</h2>
<p>Looking for a bank around you? a bar? Open up <a href="http://www.tweakersoft.com/mobile/aroundme.html">Around Me</a> and find what you need.<br />
Got lost. Open the Maps application and follow the path to get to your destination.</p>
<h2>Cool to program</h2>
<p>Tired of virtual machined/garbage collected languages? Looking for some new development platform to expand your knowledge and your business? Have a look at the iPhone. I bought it because of development purposed (top secret at the moment) and I ended up with the iPhone as my daily technological companion. There is plenty of tutorials, books, forums and open source code to learn from.</p>
<p><br/><br />
Probably everything I described above can be experienced with some other 3G enabled phone, except the <em>cool-to-programness</em>, which is what I appreciate mostly at the moment.</p>
]]></content:encoded>
			<wfw:commentRss>http://spreadingfunkyness.com/the-iphone-is-a/feed/</wfw:commentRss>
		<slash:comments>14</slash:comments>
		</item>
	</channel>
</rss>

