<?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</title>
	<atom:link href="http://spreadingfunkyness.com/feed/" rel="self" type="application/rss+xml" />
	<link>http://spreadingfunkyness.com</link>
	<description>RIAbilitating the Internet</description>
	<lastBuildDate>Fri, 05 Feb 2010 13:32:20 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=abc</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<cloud domain='spreadingfunkyness.com' port='80' path='/?rsscloud=notify' registerProcedure='' protocol='http-post' />
		<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
An overview of how ...]]></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" 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>
<a class="a2a_dd addtoany_share_save" href="http://www.addtoany.com/share_save?linkurl=http%3A%2F%2Fspreadingfunkyness.com%2F6-tutorials-on-copypaste-and-dragdrop-in-adobe-air%2F&amp;linkname=6%20Tutorials%20on%20Copy%26%23038%3BPaste%20and%20Drag%26%23038%3BDrop%20in%20Adobe%20Air"><img src="http://spreadingfunkyness.com/wp-content/plugins/add-to-any/share_save_120_16.gif" width="120" height="16" alt="Share/Bookmark"/></a>]]></content:encoded>
			<wfw:commentRss>http://spreadingfunkyness.com/6-tutorials-on-copypaste-and-dragdrop-in-adobe-air/feed/</wfw:commentRss>
		<slash:comments>0</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" 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> each <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>
<a class="a2a_dd addtoany_share_save" href="http://www.addtoany.com/share_save?linkurl=http%3A%2F%2Fspreadingfunkyness.com%2Fcopy-and-paste-sets-of-complex-objects-in-adobe-air%2F&amp;linkname=Copy%20and%20Paste%20Sets%20of%20Complex%20Objects%20in%20Adobe%20Air"><img src="http://spreadingfunkyness.com/wp-content/plugins/add-to-any/share_save_120_16.gif" width="120" height="16" alt="Share/Bookmark"/></a>]]></content:encoded>
			<wfw:commentRss>http://spreadingfunkyness.com/copy-and-paste-sets-of-complex-objects-in-adobe-air/feed/</wfw:commentRss>
		<slash:comments>0</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" 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>
<a class="a2a_dd addtoany_share_save" href="http://www.addtoany.com/share_save?linkurl=http%3A%2F%2Fspreadingfunkyness.com%2Fcopy-and-paste-a-complex-object-in-adobe-air%2F&amp;linkname=Copy%20and%20Paste%20a%20complex%20object%20in%20Adobe%20Air"><img src="http://spreadingfunkyness.com/wp-content/plugins/add-to-any/share_save_120_16.gif" width="120" height="16" alt="Share/Bookmark"/></a>]]></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" 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>
<a class="a2a_dd addtoany_share_save" href="http://www.addtoany.com/share_save?linkurl=http%3A%2F%2Fspreadingfunkyness.com%2Fcopy-and-paste-images-in-adobe-air%2F&amp;linkname=Copy%20and%20Paste%20Images%20in%20Adobe%20Air"><img src="http://spreadingfunkyness.com/wp-content/plugins/add-to-any/share_save_120_16.gif" width="120" height="16" alt="Share/Bookmark"/></a>]]></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" 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> each <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>
<a class="a2a_dd addtoany_share_save" href="http://www.addtoany.com/share_save?linkurl=http%3A%2F%2Fspreadingfunkyness.com%2Fdrag-and-drop-of-images-in-adobe-air%2F&amp;linkname=Drag%20and%20Drop%20of%20Images%20In%20Adobe%20Air"><img src="http://spreadingfunkyness.com/wp-content/plugins/add-to-any/share_save_120_16.gif" width="120" height="16" alt="Share/Bookmark"/></a>]]></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 has ...]]></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" 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>
<a class="a2a_dd addtoany_share_save" href="http://www.addtoany.com/share_save?linkurl=http%3A%2F%2Fspreadingfunkyness.com%2Fdrag-and-drop-of-text-in-adobe-air%2F&amp;linkname=Drag%20and%20Drop%20of%20Text%20in%20Adobe%20Air"><img src="http://spreadingfunkyness.com/wp-content/plugins/add-to-any/share_save_120_16.gif" width="120" height="16" alt="Share/Bookmark"/></a>]]></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 implementing the target ...]]></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" 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>
<a class="a2a_dd addtoany_share_save" href="http://www.addtoany.com/share_save?linkurl=http%3A%2F%2Fspreadingfunkyness.com%2Fnative-drag-and-drop-in-adobe-air%2F&amp;linkname=Native%20Drag%20and%20Drop%20in%20Adobe%20Air"><img src="http://spreadingfunkyness.com/wp-content/plugins/add-to-any/share_save_120_16.gif" width="120" height="16" alt="Share/Bookmark"/></a>]]></content:encoded>
			<wfw:commentRss>http://spreadingfunkyness.com/native-drag-and-drop-in-adobe-air/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>&#8220;An automated WordPress update has failed to complete&#8221;</title>
		<link>http://spreadingfunkyness.com/an-automated-wordpress-update-has-failed-to-complete/</link>
		<comments>http://spreadingfunkyness.com/an-automated-wordpress-update-has-failed-to-complete/#comments</comments>
		<pubDate>Wed, 13 Jan 2010 14:32:15 +0000</pubDate>
		<dc:creator>Cesare</dc:creator>
				<category><![CDATA[wordpress]]></category>

		<guid isPermaLink="false">http://spreadingfunkyness.com/?p=291</guid>
		<description><![CDATA[How to solve the "An automated WordPress update has failed to complete" case.]]></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%2Fan-automated-wordpress-update-has-failed-to-complete%2F"><br />
				<img src="http://api.tweetmeme.com/imagebutton.gif?url=http%3A%2F%2Fspreadingfunkyness.com%2Fan-automated-wordpress-update-has-failed-to-complete%2F&amp;source=_funkyboy&amp;style=normal&amp;service=bit.ly" height="61" width="50" /><br />
			</a>
		</div>
<p>When you upgrade to a new version of Wordpress sometimes the procedure &#8220;forgets&#8221; to clean up the stuff downloaded to perform the update. Sometimes, this depends on various factors (wordpress version, hosting, etc.), the upgrade is successful but a message appears on your dashboard: &#8220;An automated WordPress update has failed to complete&#8221;, though a bit more below it says you are using the updated version of wordpress. I usually solve this situation by:</p>
<ul>
<li>deleting the upgrade folder into ./wp-content</li>
<li>deleting the .maintenance file into the wordpress root.</li>
</ul>
<p>The second step might be a bit tricky for non-expert. You need an ftp client which allows visualizing hidden files (those beginning with a dot). Then you can select it and delete it. </p>
<p>If you solve this issue in a different way I&#8217;m glad to hear your opinion in the comments below.</p>
<a class="a2a_dd addtoany_share_save" href="http://www.addtoany.com/share_save?linkurl=http%3A%2F%2Fspreadingfunkyness.com%2Fan-automated-wordpress-update-has-failed-to-complete%2F&amp;linkname=%26%238220%3BAn%20automated%20WordPress%20update%20has%20failed%20to%20complete%26%238221%3B"><img src="http://spreadingfunkyness.com/wp-content/plugins/add-to-any/share_save_120_16.gif" width="120" height="16" alt="Share/Bookmark"/></a>]]></content:encoded>
			<wfw:commentRss>http://spreadingfunkyness.com/an-automated-wordpress-update-has-failed-to-complete/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Choices when Designing for Social &#8211; Renaming allowed?</title>
		<link>http://spreadingfunkyness.com/choices-when-designing-for-social-renaming-allowed/</link>
		<comments>http://spreadingfunkyness.com/choices-when-designing-for-social-renaming-allowed/#comments</comments>
		<pubDate>Mon, 21 Dec 2009 11:47:37 +0000</pubDate>
		<dc:creator>Cesare</dc:creator>
				<category><![CDATA[socialnetworks]]></category>

		<guid isPermaLink="false">http://spreadingfunkyness.com/?p=288</guid>
		<description><![CDATA[
			
				
			
		
This reflections started when a local group I subscribed on Facebook changed its name. A while ago, the administrator started a group about my region and its residents. When I subscribed I thought: &#8220;It is a pretty common practice, somebody feels the need to create a group about a shared interest&#8221;. I thought it was ...]]></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%2Fchoices-when-designing-for-social-renaming-allowed%2F"><br />
				<img src="http://api.tweetmeme.com/imagebutton.gif?url=http%3A%2F%2Fspreadingfunkyness.com%2Fchoices-when-designing-for-social-renaming-allowed%2F&amp;source=_funkyboy&amp;style=normal&amp;service=bit.ly" height="61" width="50" /><br />
			</a>
		</div>
<p>This reflections started when a local group I subscribed on Facebook changed its name. A while ago, the administrator started a group about my region and its residents. When I subscribed I thought: &#8220;It is a pretty common practice, somebody feels the need to create a group about a shared interest&#8221;. I thought it was a good idea and so did many. I still think it is a good idea but not when the following happens. The administrator of the group is also an organizer of local parties. Recently he changed the name of the group, from the generic name of the region to the name of a party! You might think: &#8220;He is dishonest, a profiteer!&#8221;. I think so, but my reflections got immediately over, to the platform on the backstage.<br />
<strong>Why did Facebook designers allowed the possibility to rename a group?</strong> By designers here I mean Interaction Designer, people who thought and reflected on the dynamics implemented in the platform (e.g. you can see the pictures of your friends, friends can post on your wall, etc.) This features, consciously or not, are the reflections of design choices, and any designer who as worked on social products had been in front of junctions like: should we allow this or not? why?<br />
I am wondering, why on earth Facebook designers allowed group renaming? Have you ever been in a real world group? I did. Have you ever participated to a group that changed its name? I did. Before renaming, the new name (and goals of the group) have been discussed by the WHOLE group. Here I am not trying to defend the party organizer, he did his part, but I am ascribing some responsibility to the designers. If a platform enables such a behavior it is not well designed, and in front of such episodes people might loose trust in the platform itself. The possibility of renaming a group enables everybody with some charisma to collect &#8220;friends&#8221; and cheat on them. My boss is happy because I joined the charity group, and the day after I am fired because the group name changed to &#8220;Satan apostles&#8221;.<br />
I am not blaming the WHOLE Facebook, for it allowed me to get some job and to get in touch with old friends I&#8217;d have never met otherwise, but I am just reflecting on a single (apparently) little feature which enables a sort of anti-social behavior.<br />
Let me close with a thought from a development view point: how many meanings depend on the change of a string? :)</p>
<a class="a2a_dd addtoany_share_save" href="http://www.addtoany.com/share_save?linkurl=http%3A%2F%2Fspreadingfunkyness.com%2Fchoices-when-designing-for-social-renaming-allowed%2F&amp;linkname=Choices%20when%20Designing%20for%20Social%20%26%238211%3B%20Renaming%20allowed%3F"><img src="http://spreadingfunkyness.com/wp-content/plugins/add-to-any/share_save_120_16.gif" width="120" height="16" alt="Share/Bookmark"/></a>]]></content:encoded>
			<wfw:commentRss>http://spreadingfunkyness.com/choices-when-designing-for-social-renaming-allowed/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>News Feed for iPhone Developers</title>
		<link>http://spreadingfunkyness.com/news-feed-for-iphone-developers/</link>
		<comments>http://spreadingfunkyness.com/news-feed-for-iphone-developers/#comments</comments>
		<pubDate>Thu, 10 Dec 2009 11:53:24 +0000</pubDate>
		<dc:creator>Cesare</dc:creator>
				<category><![CDATA[apple]]></category>
		<category><![CDATA[iphone]]></category>

		<guid isPermaLink="false">http://spreadingfunkyness.com/?p=285</guid>
		<description><![CDATA[
			
				
			
		
A few days ago, as many developers, I got the following message from Apple.

I think it is a good step towards developers. A small one, but towards. The feed, publicly available, includes tips about submission and general news. For example, iTunes connect will be down from Dec 23rd to 28th. An encouraging news is that ...]]></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%2Fnews-feed-for-iphone-developers%2F"><br />
				<img src="http://api.tweetmeme.com/imagebutton.gif?url=http%3A%2F%2Fspreadingfunkyness.com%2Fnews-feed-for-iphone-developers%2F&amp;source=_funkyboy&amp;style=normal&amp;service=bit.ly" height="61" width="50" /><br />
			</a>
		</div>
<p>A few days ago, as many developers, I got the following message from Apple.<br />
<img src="http://spreadingfunkyness.com/wp-content/uploads/2009/12/Screen-shot-2009-12-09-at-12.42.25-AM-300x283.gif" alt="Message from Apple" title="Message from Apple" width="300" height="283" class="aligncenter size-medium wp-image-286"/><br />
I think it is a good step towards developers. A small one, but towards. The feed, <a href="http://developer.apple.com/rss/iphonedevnews.rss">publicly available</a>, includes tips about submission and general news. For example, iTunes connect will be down from Dec 23rd to 28th. An encouraging news is that &#8220;92% of applications are being approved within 14 days&#8221;. Although this is far from <a href="http://joehewitt.com/post/innocent-until-proven-guilty/">the dream of many developers</a> I think it proves positive attitude in cultivating the relationship with the creators of iPhone applications.</p>
<p>In the meantime, acceptance <a href="http://bit.ly/8KcF5R">policies are sweetening</a>.</p>
<a class="a2a_dd addtoany_share_save" href="http://www.addtoany.com/share_save?linkurl=http%3A%2F%2Fspreadingfunkyness.com%2Fnews-feed-for-iphone-developers%2F&amp;linkname=News%20Feed%20for%20iPhone%20Developers"><img src="http://spreadingfunkyness.com/wp-content/plugins/add-to-any/share_save_120_16.gif" width="120" height="16" alt="Share/Bookmark"/></a>]]></content:encoded>
			<wfw:commentRss>http://spreadingfunkyness.com/news-feed-for-iphone-developers/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
