<?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>Saturnboy &#187; drag-and-drop</title>
	<atom:link href="http://saturnboy.com/tag/drag-and-drop/feed/" rel="self" type="application/rss+xml" />
	<link>http://saturnboy.com</link>
	<description>Code, Work, and Life</description>
	<lastBuildDate>Thu, 01 Mar 2012 22:35:28 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.2.1</generator>
		<item>
		<title>Drag-and-Drop Revisited</title>
		<link>http://saturnboy.com/2010/12/drag-and-drop-revisited/</link>
		<comments>http://saturnboy.com/2010/12/drag-and-drop-revisited/#comments</comments>
		<pubDate>Wed, 15 Dec 2010 04:02:54 +0000</pubDate>
		<dc:creator>justin</dc:creator>
				<category><![CDATA[Code]]></category>
		<category><![CDATA[drag-and-drop]]></category>
		<category><![CDATA[flex4]]></category>
		<category><![CDATA[skinning]]></category>
		<category><![CDATA[ux]]></category>

		<guid isPermaLink="false">http://saturnboy.com/?p=1668</guid>
		<description><![CDATA[It&#8217;s time to revisit drag-and-drop in Flex 4. For a long time now, my previous Drag-and-Drop in Flex 4 post has been the most popular post on this blog. I get something like 1,200 pageview/month on that one post. This time around, I&#8217;ll try to expand on the thinking that goes on before I write [...]]]></description>
			<content:encoded><![CDATA[<p>It&#8217;s time to revisit drag-and-drop in Flex 4.  For a long time now, my previous <a href="http://saturnboy.com/2009/08/drag-and-drop-flex-4/">Drag-and-Drop in Flex 4</a> post has been the most popular post on this blog.  I get something like 1,200 pageview/month on that one post.  This time around, I&#8217;ll try to expand on the thinking that goes on <i>before</i> I write the code to add drag-and-drop functionality to an app.</p>
<h3>UX 101</h3>
<p>It is impossible to develop an RIA without some basic understanding of interaction design.  As they say in one of my favorite movies, &quot;Many men have tried.  They tried and failed?  They tried and died.&quot;  So a short UX primer on drag-and-drop goes like this&#8230;</p>
<p>Users are typically familiar with drag-and-drop for two basic actions: moving-stuff-around and putting-stuff-into.  For example, we move windows around the desktop or move songs around in a playlist or move icons around in a folder.  Also, we put stuff into the trash or put a picture into an album or put an attachment into an email.  At a fundmental level, users have an understanding of these actions because they mimic the physical world.  Performing these actions via a touch interface (rather than a mouse) is even better, but that&#8217;s a story for another day.</p>
<p class="bottom">Given these two basic actions, I&#8217;m going to design a sample app that exercises them both.  This is what I came up with:</p>
<div class="span-14 last">
<img src="http://saturnboy.com/proj/flex4/drag_drop/colors/diagrams/drag-drop-diagram1.png" alt="diagram 1" title="diagram 1" width="490" height="327" />
</div>
<p>Our sample app has three drag actions.  In #1, you can drag to put items from the palette into the list.  In #2a and #2b, you can drag items from the list into a target box (that preforms some action).  In #3, you can drag items around inside the list to reorder them.  I&#8217;ll break them down one by one.</p>
<h3>#1 &mdash; Drag List Item to Another List</h3>
<p class="bottom">Dragging from one list and dropping on another is super easy in Flex 4.  Here&#8217;s a snippet:</p>

<div class="wp_syntax"><div class="code"><pre class="mxml" style="font-family:monospace;"><span style="color: #000000;"><span style="color: #7400FF;">&lt;s:List</span> id=<span style="color: #ff0000;">&quot;sourceList&quot;</span> dragEnabled=<span style="color: #ff0000;">&quot;true&quot;</span><span style="color: #7400FF;">&gt;</span></span>
    <span style="color: #000000;"><span style="color: #7400FF;">&lt;s:ArrayList</span> source=<span style="color: #ff0000;">&quot;['A','B','C','D']&quot;</span> <span style="color: #7400FF;">/&gt;</span></span>
<span style="color: #000000;"><span style="color: #7400FF;">&lt;/s:List</span><span style="color: #7400FF;">&gt;</span></span>
&nbsp;
<span style="color: #000000;"><span style="color: #7400FF;">&lt;s:List</span> id=<span style="color: #ff0000;">&quot;targetList&quot;</span> dropEnabled=<span style="color: #ff0000;">&quot;true&quot;</span><span style="color: #7400FF;">&gt;</span></span>
    <span style="color: #000000;"><span style="color: #7400FF;">&lt;s:ArrayList</span><span style="color: #7400FF;">&gt;</span><span style="color: #7400FF;">&lt;/s:ArrayList</span><span style="color: #7400FF;">&gt;</span></span>
<span style="color: #000000;"><span style="color: #7400FF;">&lt;/s:List</span><span style="color: #7400FF;">&gt;</span></span></pre></div></div>

<p>We set <code>dragEnable=true</code> on the source list and <code>dropEnable=true</code> on the target list.  For bi-directional drag-and-drop, just set both attributes true for both lists.  In a feat of awesomeness, Flex 4 does everything else for you.  You don&#8217;t need to listen for any events or write any handlers.  And you even get some nice eye candy for free, because the target list glows when you drag an item over it.</p>
<blockquote style="color:#333"><p><b>Trick 1</b> &mdash; When the drop target is an empty list, you <i>must</i> given it an empty <code>dataProvider</code>.  In the above example, I just use an empty <code>ArrayList</code> pair of tags in MXML, but I could just as easily say <code>dataProvider=&quot;{new ArrayList()}&quot;</code>, or even do everything in Actionscript.</p></blockquote>
<blockquote style="color:#333"><p><b>Trick 2</b> &mdash; The source list accepts a drop&mdash;if and only if&mdash;the item being dropped is compatible with the items in the target <code>dataProvider</code>.  For example, you can <i>not</i> drop a <code>Foo</code> object on a list of <code>Bar</code> objects.  Setting the target list to have an empty <code>dataProvider</code> (à la Trick 1), accepts anything.</p></blockquote>
<h3>#2 &mdash; Drag List Item to <code>UIComponent</code> Target</h3>
<p class="bottom">Again, to use a list as the drag source, we just set <code>dragEnable=true</code>.  But this time the target is some non-<code>List</code> <code>UIComponent</code>, so we need to do what we <a href="http://saturnboy.com/2009/08/drag-and-drop-flex-4/">always do</a> to enable drop functionality on a component&mdash;namely, attach handlers to the <code>dragEnter</code> and <code>dragDrop</code> events.  Here&#8217;s a snippet:</p>

<div class="wp_syntax"><div class="code"><pre class="mxml" style="font-family:monospace;"><span style="color: #000000;"><span style="color: #7400FF;">&lt;s:List</span> id=<span style="color: #ff0000;">&quot;sourceList&quot;</span> dragEnabled=<span style="color: #ff0000;">&quot;true&quot;</span><span style="color: #7400FF;">&gt;</span></span>
    <span style="color: #000000;"><span style="color: #7400FF;">&lt;s:ArrayList</span> source=<span style="color: #ff0000;">&quot;['A','B','C','D']&quot;</span> <span style="color: #7400FF;">/&gt;</span></span>
<span style="color: #000000;"><span style="color: #7400FF;">&lt;/s:List</span><span style="color: #7400FF;">&gt;</span></span>
&nbsp;
<span style="color: #000000;"><span style="color: #7400FF;">&lt;s:Panel</span> id=<span style="color: #ff0000;">&quot;targetA&quot;</span> </span>
<span style="color: #000000;">         dragEnter=<span style="color: #ff0000;">&quot;dragEnterHandler(event)&quot;</span></span>
<span style="color: #000000;">         dragDrop=<span style="color: #ff0000;">&quot;dragDropHandler(event)&quot;</span><span style="color: #7400FF;">&gt;</span></span>
<span style="color: #000000;"><span style="color: #7400FF;">&lt;/s:Panel</span><span style="color: #7400FF;">&gt;</span></span></pre></div></div>

<p class="bottom">And here are the handlers:</p>

<div class="wp_syntax"><div class="code"><pre class="actionscript" style="font-family:monospace;"><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>:DragEvent<span style="color: #66cc66;">&#41;</span>:<span style="color: #0066CC;">void</span> <span style="color: #66cc66;">&#123;</span>
    DragManager.<span style="color: #006600;">acceptDragDrop</span><span style="color: #66cc66;">&#40;</span><span style="color: #0066CC;">e</span>.<span style="color: #006600;">currentTarget</span> as IUIComponent<span style="color: #66cc66;">&#41;</span>;
<span style="color: #66cc66;">&#125;</span>
<span style="color: #0066CC;">private</span> <span style="color: #000000; font-weight: bold;">function</span> dragDropHandler<span style="color: #66cc66;">&#40;</span><span style="color: #0066CC;">e</span>:DragEvent<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;">//do something with dropped item here</span>
<span style="color: #66cc66;">&#125;</span></pre></div></div>

<p>As always, we <i>accept</i> the drop in the <code>dragEnter</code> handler via the static <code>acceptDragDrop()</code> method on the <code>DragManager</code>.  And once the object is dropped, we can do whatever we want with it in the <code>dragDrop</code> handler.</p>
<h3>#3 &mdash; Drag List Item to Reorder Items</h3>
<p class="bottom">Finally, we want to be able to reorder the items in a list.  Again, the spark <code>List</code> does all the work for us.  We just set both <code>dragEnable=true</code> and <code>dropEnable=true</code> on the list we want to reorder.  We must also set the magical <code>dragMoveEnabled=true</code>, which has numerous ramifications. Here is the snippet:</p>

<div class="wp_syntax"><div class="code"><pre class="mxml" style="font-family:monospace;"><span style="color: #000000;"><span style="color: #7400FF;">&lt;s:List</span> id=<span style="color: #ff0000;">&quot;reorderList&quot;</span></span>
<span style="color: #000000;">        dragEnabled=<span style="color: #ff0000;">&quot;true&quot;</span></span>
<span style="color: #000000;">        dropEnabled=<span style="color: #ff0000;">&quot;true&quot;</span></span>
<span style="color: #000000;">        dragMoveEnabled=<span style="color: #ff0000;">&quot;true&quot;</span><span style="color: #7400FF;">&gt;</span></span>
    <span style="color: #000000;"><span style="color: #7400FF;">&lt;s:ArrayList</span> source=<span style="color: #ff0000;">&quot;['A','B','C','D']&quot;</span> <span style="color: #7400FF;">/&gt;</span></span>
<span style="color: #000000;"><span style="color: #7400FF;">&lt;/s:List</span><span style="color: #7400FF;">&gt;</span></span></pre></div></div>

<p>The code is trivial, but what&#8217;s going on with <code>dragMoveEnabled=true</code>?  Well, <code>dragMoveEnable</code>, which defaults to <code>false</code>, controls whether or not an object is <i>moved</i> (aka removed from the source and added to the target) or <i>copied</i> (aka added to the target leaving the source untouched).  So to reorder the items in a list, we need the <i>move</i> behavior, thus we set <code>dragMoveEnabled=true</code>.</p>
<blockquote style="color:#333"><p><b>Trick 3</b> &mdash; If the source list is <code>dragMoveEnabled=true</code> and the target is a non-<code>List</code> <code>UIComponent</code>, you will see some seemingly <i>odd</i> behavior.  Every time to drop an object on your component, it will be deleted from the source list.  This is because you are only seeing the first half of the <i>move</i> (the item is removed from the source), and not the second half (the item is added to the target) because the target is not a <code>List</code>.</p></blockquote>
<blockquote style="color:#333"><p><b>Trick 4</b> &mdash; As an alternative to <code>dragMoveEnabled=true</code>, you can make a call to  <code>DragManager.showFeedback(DragManager.MOVE)</code> in the <code>dragEnter</code> handler to control whether or not an object is <i>moved</i> or <i>copied</i>.  Do <i>NOT</i> use both <code>showFeedback</code> and <code>dragMoveEnabled</code> at the same time.</p></blockquote>
<h3>Eye candy</h3>
<p>What&#8217;s a Flex app without eye candy?  But with drag-and-drop, I&#8217;d say most of the eye candy is more of a UX necessity than anything else.  It&#8217;s used to indicate potential drop targets, or highlight a target that is ready to receive a drop, etc.</p>
<h5>Glow On Enter</h5>
<p class="bottom">With list to list drag-and-drop, we get a glow on the target list for free, which tells the user that the target list is ready to receive the drop.  But when dragging to a non-<code>List</code> <code>UIComponent</code>, we need to add the glow ourselves:</p>

<div class="wp_syntax"><div class="code"><pre class="actionscript" style="font-family:monospace;"><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>:DragEvent<span style="color: #66cc66;">&#41;</span>:<span style="color: #0066CC;">void</span> <span style="color: #66cc66;">&#123;</span>
    myGlow.<span style="color: #006600;">alpha</span> = <span style="color: #cc66cc;">1</span>;
    DragManager.<span style="color: #006600;">acceptDragDrop</span><span style="color: #66cc66;">&#40;</span><span style="color: #0066CC;">e</span>.<span style="color: #006600;">currentTarget</span> as IUIComponent<span style="color: #66cc66;">&#41;</span>;
<span style="color: #66cc66;">&#125;</span>
<span style="color: #0066CC;">private</span> <span style="color: #000000; font-weight: bold;">function</span> dragExitHandler<span style="color: #66cc66;">&#40;</span><span style="color: #0066CC;">e</span>:DragEvent<span style="color: #66cc66;">&#41;</span>:<span style="color: #0066CC;">void</span> <span style="color: #66cc66;">&#123;</span>
    myGlow.<span style="color: #006600;">alpha</span> = <span style="color: #cc66cc;">0</span>;
<span style="color: #66cc66;">&#125;</span>
<span style="color: #0066CC;">private</span> <span style="color: #000000; font-weight: bold;">function</span> dragDropHandler<span style="color: #66cc66;">&#40;</span><span style="color: #0066CC;">e</span>:DragEvent<span style="color: #66cc66;">&#41;</span>:<span style="color: #0066CC;">void</span> <span style="color: #66cc66;">&#123;</span>
    myGlow.<span style="color: #006600;">alpha</span> = <span style="color: #cc66cc;">0</span>;
    <span style="color: #808080; font-style: italic;">//do something with dropped item here</span>
<span style="color: #66cc66;">&#125;</span></pre></div></div>

<p class="bottom">In the <code>dragEnter</code> handler, we turn the glow on, and we turn the glow off on either a <code>dragExit</code> or <code>dragDrop</code> event.  And we need to add a simple <code>GlowFilter</code> to the target component:</p>

<div class="wp_syntax"><div class="code"><pre class="mxml" style="font-family:monospace;"><span style="color: #000000;"><span style="color: #7400FF;">&lt;s:Panel</span> id=<span style="color: #ff0000;">&quot;targetA&quot;</span> </span>
<span style="color: #000000;">         dragEnter=<span style="color: #ff0000;">&quot;dragEnterHandler(event)&quot;</span></span>
<span style="color: #000000;">         dragDrop=<span style="color: #ff0000;">&quot;dragDropHandler(event)&quot;</span><span style="color: #7400FF;">&gt;</span></span>
    <span style="color: #000000;"><span style="color: #7400FF;">&lt;s:filters</span><span style="color: #7400FF;">&gt;</span></span>
        <span style="color: #000000;"><span style="color: #7400FF;">&lt;s:GlowFilter</span> id=<span style="color: #ff0000;">&quot;myGlow&quot;</span> blurX=<span style="color: #ff0000;">&quot;16&quot;</span> blurY=<span style="color: #ff0000;">&quot;16&quot;</span></span>
<span style="color: #000000;">                color=<span style="color: #ff0000;">&quot;#3399ff&quot;</span> alpha=<span style="color: #ff0000;">&quot;0&quot;</span> <span style="color: #7400FF;">/&gt;</span></span>
    <span style="color: #000000;"><span style="color: #7400FF;">&lt;/s:filters</span><span style="color: #7400FF;">&gt;</span></span>
<span style="color: #000000;"><span style="color: #7400FF;">&lt;/s:Panel</span><span style="color: #7400FF;">&gt;</span></span></pre></div></div>

<p>No magic, just use MXML to add a <code>GlowFilter</code> to the target component, which in this snippet is a spark <code>Panel</code> component.</p>
<h5>Custom Drag Proxy</h5>
<p>Customizing the drag proxy (what an item looks like while dragging) is fun, but <a href="http://saturnboy.com/2009/08/drag-and-drop-flex-4/">I covered that previously</a>, so there&#8217;s no need to revisit it here.  On the other hand, I haven&#8217;t discussed how to customizing an item dragged from a spark <code>List</code> yet.  It is not only fun, but also quite a bit easier.</p>
<p class="bottom">Flex 4 makes is super easy to create a custom drag proxy by simply adding a magic <code>dragging</code> state to the <code>List</code>&#8216;s <code>itemRenderer</code>.  For this snippet, imagine I have a trivial <code>ItemRenderer</code> that just shows a centered label with black text, but when it&#8217;s being dragged I want to turn the text red:</p>

<div class="wp_syntax"><div class="code"><pre class="mxml" style="font-family:monospace;"><span style="color: #000000;">&lt;?xml version=<span style="color: #ff0000;">&quot;1.0&quot;</span> encoding=<span style="color: #ff0000;">&quot;utf-8&quot;</span>?<span style="color: #7400FF;">&gt;</span></span>
<span style="color: #000000;"><span style="color: #7400FF;">&lt;s:ItemRenderer</span> ...<span style="color: #7400FF;">&gt;</span></span>
    <span style="color: #000000;"><span style="color: #7400FF;">&lt;s:states</span><span style="color: #7400FF;">&gt;</span></span>
        <span style="color: #000000;"><span style="color: #7400FF;">&lt;s:State</span> name=<span style="color: #ff0000;">&quot;normal&quot;</span> <span style="color: #7400FF;">/&gt;</span></span>
        <span style="color: #000000;"><span style="color: #7400FF;">&lt;s:State</span> name=<span style="color: #ff0000;">&quot;hovered&quot;</span> <span style="color: #7400FF;">/&gt;</span></span>
        <span style="color: #000000;"><span style="color: #7400FF;">&lt;s:State</span> name=<span style="color: #ff0000;">&quot;selected&quot;</span> <span style="color: #7400FF;">/&gt;</span></span>
        <span style="color: #000000;"><span style="color: #7400FF;">&lt;s:State</span> name=<span style="color: #ff0000;">&quot;dragging&quot;</span><span style="color: #7400FF;">/&gt;</span></span>
    <span style="color: #000000;"><span style="color: #7400FF;">&lt;/s:states</span><span style="color: #7400FF;">&gt;</span></span>
&nbsp;
    <span style="color: #000000;"><span style="color: #7400FF;">&lt;s:Label</span> left=<span style="color: #ff0000;">&quot;0&quot;</span> right=<span style="color: #ff0000;">&quot;0&quot;</span> top=<span style="color: #ff0000;">&quot;0&quot;</span> bottom=<span style="color: #ff0000;">&quot;0&quot;</span></span>
<span style="color: #000000;">            text=<span style="color: #ff0000;">&quot;{data.label}&quot;</span> textAlign=<span style="color: #ff0000;">&quot;center&quot;</span> verticalAlign=<span style="color: #ff0000;">&quot;middle&quot;</span></span>
<span style="color: #000000;">            color=<span style="color: #ff0000;">&quot;#000000&quot;</span></span>
<span style="color: #000000;">            color.hovered=<span style="color: #ff0000;">&quot;#0000ff&quot;</span></span>
<span style="color: #000000;">            color.dragging=<span style="color: #ff0000;">&quot;#ff0000&quot;</span> <span style="color: #7400FF;">/&gt;</span></span>
<span style="color: #000000;"><span style="color: #7400FF;">&lt;/s:ItemRenderer</span><span style="color: #7400FF;">&gt;</span></span></pre></div></div>

<p>As you can see from the above code, customizing the drag indicator is a <i>huge</i> nothing.  Just add the magic <code>dragging</code> state to the list of states, and use Flex 4&#8242;s inline state syntax to do whatever you want.  In this snippet, we set <code>color.dragging=&quot;#ff0000&quot;</code> to turn the text red when its being dragged.  The sample app below does quite a few more things to customize the dragged item, so check out that code too.</p>
<h5>Custom Drop Indicator</h5>
<p>When a user drags an item over a target spark <code>List</code>, a line appears to show the user where the item will be inserted.  This line is known as the <i>drop indicator</i>.  To change things up, we will make a custom drop indicator that is a dashed line.</p>
<blockquote style="color:#333"><p><b>Trick 5</b> &mdash; Alas, Flex 4 does not have direct support for dashed strokes, so we need to fake it.  The easy way to make a dashed line in Flex 4 is to use <code>BitmapFill</code>.  First, we create an image that is a tileable pattern of squares.  Then, we make a <code>Rect</code> and set its fill to <code>BitmapFill</code> and <code>fillMode=&quot;repeat&quot;</code>.</p></blockquote>
<p class="bottom">The <code>dropIndicator</code> component is found in the <code>fx:Declarations</code> block of the default spark <code>ListSkin</code>, so we must create a custom <code>List</code> skin with our custom <code>dropIndicator</code> component.  Here&#8217;s a snippet from our custom skin&#8217;s <code>fx:Declarations</code> block:</p>

<div class="wp_syntax"><div class="code"><pre class="mxml" style="font-family:monospace;"><span style="color: #000000;"><span style="color: #7400FF;">&lt;fx:Declarations</span><span style="color: #7400FF;">&gt;</span></span>
    <span style="color: #000000;"><span style="color: #7400FF;">&lt;fx:Component</span> id=<span style="color: #ff0000;">&quot;dropIndicator&quot;</span><span style="color: #7400FF;">&gt;</span></span>
        <span style="color: #000000;"><span style="color: #7400FF;">&lt;s:Group</span> minWidth=<span style="color: #ff0000;">&quot;1&quot;</span> minHeight=<span style="color: #ff0000;">&quot;1&quot;</span> maxWidth=<span style="color: #ff0000;">&quot;1&quot;</span> maxHeight=<span style="color: #ff0000;">&quot;1&quot;</span><span style="color: #7400FF;">&gt;</span></span>
            <span style="color: #000000;"><span style="color: #7400FF;">&lt;s:Rect</span> left=<span style="color: #ff0000;">&quot;0&quot;</span> right=<span style="color: #ff0000;">&quot;0&quot;</span> top=<span style="color: #ff0000;">&quot;0&quot;</span> bottom=<span style="color: #ff0000;">&quot;0&quot;</span><span style="color: #7400FF;">&gt;</span></span>
                <span style="color: #000000;"><span style="color: #7400FF;">&lt;s:fill</span><span style="color: #7400FF;">&gt;</span></span>
                    <span style="color: #000000;"><span style="color: #7400FF;">&lt;s:BitmapFill</span> source=<span style="color: #ff0000;">&quot;@Embed('dash.png')&quot;</span></span>
<span style="color: #000000;">                            fillMode=<span style="color: #ff0000;">&quot;repeat&quot;</span> <span style="color: #7400FF;">/&gt;</span></span>
                <span style="color: #000000;"><span style="color: #7400FF;">&lt;/s:fill</span><span style="color: #7400FF;">&gt;</span></span>
            <span style="color: #000000;"><span style="color: #7400FF;">&lt;/s:Rect</span><span style="color: #7400FF;">&gt;</span></span>
        <span style="color: #000000;"><span style="color: #7400FF;">&lt;/s:Group</span><span style="color: #7400FF;">&gt;</span></span>
    <span style="color: #000000;"><span style="color: #7400FF;">&lt;/fx:Component</span><span style="color: #7400FF;">&gt;</span></span>
<span style="color: #000000;"><span style="color: #7400FF;">&lt;/fx:Declarations</span><span style="color: #7400FF;">&gt;</span></span></pre></div></div>

<p>As described above, we have a <code>Rect</code> with a <code>BitmapFill</code>, and an image <code>dash.png</code> that is a tileable pattern of squares.  But the real magic is in the <code>Group</code> wrapper, by setting all of <code>minWidth</code>, <code>maxWidth</code>, <code>minHeight</code>, <code>maxHeight</code> to 1px we ensure we get a one pixel line as our drop indicator independent of the layout applied to our <code>List</code>.  This is because <code>HorizontalLayout</code> ignore min and max height, and <code>VerticalLayout</code> ignore min and max width.  So if we take a 1px view of our pattern of squares, we see dashes.</p>
<h3>Conclusion</h3>
<p class="bottom">Here&#8217;s the complete drag-and-drop sample (view source enabled):</p>
<div id="flashcontent-drag-drop-colors">
Flash is required.  <a href="http://www.adobe.com/go/getflashplayer">Get it here!</a>
</div>
<p>Hopefully, I covered the full spectrum of drag-and-drop functionality that the average Flex app (or even above average) is ever likely to need.  If you want more, check out the links below, or just leave me a comment.</p>
<h5>Useful Links</h5>
<ul>
<li>My first post on <a href="http://saturnboy.com/2009/08/drag-and-drop-flex-4/">drag-and-drop in Flex 4</a> covered a lot of drag proxy stuff.</li>
<li>Flex After Dark has a solid <a href="http://www.flexafterdark.com/tutorials/Flex-Drag-and-Drop">drag-and-drop tutorial</a> that is definitely worth reading if you are implementing drag-and-drop functionality in your app.</li>
<li>Evtim, aka The Godfather, as I like to call him, has a <a href="http://evtimmy.com/2010/01/drag-and-drop-skinning-in-spark/">cool post</a> on customizing both the drag indicator and the drop indicator of the spark <code>List</code> component.</li>
</ul>
<h5>Files</h5>
<ul>
<li><a href="http://saturnboy.com/proj/flex4/drag_drop/colors/DragDropColors.html">DragDropColors</a> (<a href="http://saturnboy.com/proj/flex4/drag_drop/colors/srcview/DragDropColors.zip">download</a>)</li>
</ul>
<div>
<script type="text/javascript">
swfobject.embedSWF('http://saturnboy.com/proj/flex4/drag_drop/colors/DragDropColors.swf', 'flashcontent-drag-drop-colors', '510', '380', '10.1.0', 'playerProductInstall.swf', false, { bgColor:'#f8f8f8', base:'.' });
</script>
</div>
]]></content:encoded>
			<wfw:commentRss>http://saturnboy.com/2010/12/drag-and-drop-revisited/feed/</wfw:commentRss>
		<slash:comments>12</slash:comments>
		</item>
		<item>
		<title>Drag-and-Drop in Flex 4</title>
		<link>http://saturnboy.com/2009/08/drag-and-drop-flex-4/</link>
		<comments>http://saturnboy.com/2009/08/drag-and-drop-flex-4/#comments</comments>
		<pubDate>Thu, 06 Aug 2009 02:40:52 +0000</pubDate>
		<dc:creator>justin</dc:creator>
				<category><![CDATA[Code]]></category>
		<category><![CDATA[drag-and-drop]]></category>
		<category><![CDATA[flex4]]></category>
		<category><![CDATA[fxg]]></category>

		<guid isPermaLink="false">http://saturnboy.com/?p=672</guid>
		<description><![CDATA[UPDATE: I have another Drag-and-Drop Revisited post that covers even more drag-and-drop functionality available in Flex 4. The Flex 4 gods were kind to us developers when they made the great decision to leave the custom drag-and-drop support unchanged. We just do what we&#8217;ve always done: detect the user is trying to drag something via [...]]]></description>
			<content:encoded><![CDATA[<p><b>UPDATE:</b> I have another <a href="http://saturnboy.com/2010/12/drag-and-drop-revisited/">Drag-and-Drop Revisited</a> post that covers even more drag-and-drop functionality available in Flex 4.</p>
<p>The Flex 4 gods were kind to us developers when they made the great decision to leave the custom drag-and-drop support unchanged.  We just do what we&#8217;ve always done: detect the user is trying to drag something via <code>mouseDown</code> or <code>mouseMove</code> and then add both <code>dragEnter</code> and <code>dragDrop</code> event handlers to the drop target.  So there is nothing in this post that&#8217;s not basically identical to Flex 3, except the coolness of FXG (which you can easily mimic with <a href="http://www.degrafa.org/">Degrafa</a> in Flex 3).</p>
<h5>Simple Drag-and-Drop</h5>
<p class="bottom">I&#8217;ll begin with a basic Flex 4 application.  We have two draggable graphics (a <code>Rect</code> and an <code>Ellipse</code>) in the left panel, and a target panel on the right:</p>

<div class="wp_syntax"><div class="code"><pre class="mxml" style="font-family:monospace;"><span style="color: #000000;">&lt;?xml version=<span style="color: #ff0000;">&quot;1.0&quot;</span> encoding=<span style="color: #ff0000;">&quot;utf-8&quot;</span>?<span style="color: #7400FF;">&gt;</span></span>
<span style="color: #000000;"><span style="color: #7400FF;">&lt;s:Application</span></span>
<span style="color: #000000;">        xmlns:fx=<span style="color: #ff0000;">&quot;http://ns.adobe.com/mxml/2009&quot;</span></span>
<span style="color: #000000;">        xmlns:s=<span style="color: #ff0000;">&quot;library://ns.adobe.com/flex/spark&quot;</span><span style="color: #7400FF;">&gt;</span></span>
&nbsp;
    <span style="color: #000000;"><span style="color: #7400FF;">&lt;fx:Script</span><span style="color: #7400FF;">&gt;</span></span>
        <span style="color: #000000;">&lt;!<span style="color: #66cc66;">&#91;</span>CDATA<span style="color: #66cc66;">&#91;</span></span>
<span style="color: #000000;">            imports...</span>
&nbsp;
<span style="color: #000000;">            private function mouseDownHandler<span style="color: #66cc66;">&#40;</span>e:MouseEvent<span style="color: #66cc66;">&#41;</span>:void <span style="color: #66cc66;">&#123;</span></span>
<span style="color: #000000;">                DragManager.doDrag<span style="color: #66cc66;">&#40;</span>e.currentTarget as IUIComponent, null, e<span style="color: #66cc66;">&#41;</span>;</span>
<span style="color: #000000;">            <span style="color: #66cc66;">&#125;</span></span>
&nbsp;
<span style="color: #000000;">            private function dragEnterHandler<span style="color: #66cc66;">&#40;</span>e:DragEvent<span style="color: #66cc66;">&#41;</span>:void <span style="color: #66cc66;">&#123;</span></span>
<span style="color: #000000;">                DragManager.acceptDragDrop<span style="color: #66cc66;">&#40;</span>e.currentTarget as IUIComponent<span style="color: #66cc66;">&#41;</span>;</span>
<span style="color: #000000;">            <span style="color: #66cc66;">&#125;</span></span>
&nbsp;
<span style="color: #000000;">            private function dragDropHandler<span style="color: #66cc66;">&#40;</span>e:DragEvent<span style="color: #66cc66;">&#41;</span>:void <span style="color: #66cc66;">&#123;</span></span>
<span style="color: #000000;">                e.currentTarget.addElement<span style="color: #66cc66;">&#40;</span>e.dragInitiator<span style="color: #66cc66;">&#41;</span>;</span>
<span style="color: #000000;">            <span style="color: #66cc66;">&#125;</span></span>
<span style="color: #000000;">        <span style="color: #66cc66;">&#93;</span><span style="color: #66cc66;">&#93;</span><span style="color: #7400FF;">&gt;</span></span>
    <span style="color: #000000;"><span style="color: #7400FF;">&lt;/fx:Script</span><span style="color: #7400FF;">&gt;</span></span>
&nbsp;
    <span style="color: #000000;"><span style="color: #7400FF;">&lt;s:Panel</span> title=<span style="color: #ff0000;">&quot;src&quot;</span> width=<span style="color: #ff0000;">&quot;100&quot;</span> minHeight=<span style="color: #ff0000;">&quot;133&quot;</span> x=<span style="color: #ff0000;">&quot;10&quot;</span> y=<span style="color: #ff0000;">&quot;10&quot;</span><span style="color: #7400FF;">&gt;</span></span>
        <span style="color: #000000;"><span style="color: #7400FF;">&lt;s:Graphic</span> width=<span style="color: #ff0000;">&quot;80&quot;</span> height=<span style="color: #ff0000;">&quot;80&quot;</span></span>
<span style="color: #000000;">                mouseDown=<span style="color: #ff0000;">&quot;mouseDownHandler(event)&quot;</span><span style="color: #7400FF;">&gt;</span></span>
            <span style="color: #000000;"><span style="color: #7400FF;">&lt;s:Rect</span> ... <span style="color: #7400FF;">&lt;/s:Rect</span><span style="color: #7400FF;">&gt;</span></span>
        <span style="color: #000000;"><span style="color: #7400FF;">&lt;/s:Graphic</span><span style="color: #7400FF;">&gt;</span></span>
&nbsp;
        <span style="color: #000000;"><span style="color: #7400FF;">&lt;s:Graphic</span> width=<span style="color: #ff0000;">&quot;80&quot;</span> height=<span style="color: #ff0000;">&quot;80&quot;</span></span>
<span style="color: #000000;">                mouseDown=<span style="color: #ff0000;">&quot;mouseDownHandler(event)&quot;</span><span style="color: #7400FF;">&gt;</span></span>
            <span style="color: #000000;"><span style="color: #7400FF;">&lt;s:Ellipse</span> ... <span style="color: #7400FF;">&lt;/s:Ellipse</span><span style="color: #7400FF;">&gt;</span></span>
        <span style="color: #000000;"><span style="color: #7400FF;">&lt;/s:Graphic</span><span style="color: #7400FF;">&gt;</span></span>
        ...
    <span style="color: #000000;"><span style="color: #7400FF;">&lt;/s:Panel</span><span style="color: #7400FF;">&gt;</span></span>
&nbsp;
    <span style="color: #000000;"><span style="color: #7400FF;">&lt;s:Panel</span> title=<span style="color: #ff0000;">&quot;target&quot;</span> width=<span style="color: #ff0000;">&quot;100&quot;</span> minHeight=<span style="color: #ff0000;">&quot;133&quot;</span> x=<span style="color: #ff0000;">&quot;120&quot;</span> y=<span style="color: #ff0000;">&quot;10&quot;</span></span>
<span style="color: #000000;">            dragEnter=<span style="color: #ff0000;">&quot;dragEnterHandler(event);&quot;</span></span>
<span style="color: #000000;">            dragDrop=<span style="color: #ff0000;">&quot;dragDropHandler(event);&quot;</span><span style="color: #7400FF;">&gt;</span></span>
        ...
    <span style="color: #000000;"><span style="color: #7400FF;">&lt;/s:Panel</span><span style="color: #7400FF;">&gt;</span></span>
<span style="color: #000000;"><span style="color: #7400FF;">&lt;/s:Application</span><span style="color: #7400FF;">&gt;</span></span></pre></div></div>

<p>Reading the code above, each draggable <code>Graphic</code> has a <code>mouseDown</code> handler that calls <code>DragManager.doDrag()</code> to initiate dragging.   And the target <code>Panel</code> calls <code>DragManager.acceptDragDrop()</code> on <code>dragEnter</code> and <code>addElement()</code> on <code>dragDrop</code>.  Note that since <code>Panel</code> is a Spark container we must use <code>addElement()</code> to re-parent the dropped graphic (the familiar <code>addChild()</code> is still used for Halo containers).</p>
<p class="bottom">Our simple drag-and-drop app (view source enabled):</p>
<div id="flashcontent-drag-drop">
Flash is required.  <a href="http://www.adobe.com/go/getflashplayer">Get it here!</a>
</div>
<h5>Using a FXG Drag Proxy</h5>
<p>In the example above, the moment you start dragging a component the drag proxy is displayed.  By default, the proxy is just a bounding rectangle with an alpha value of 0.5.  This is particularly noticeable and <i>lame</i> when you try to drag the pink circle.  Thankfully, we can use any display object for the drag proxy (more specifically any component that implements <code>IFlexDisplayObject</code> which includes <code>UIComponent</code> and any of its descendants).  Why not use a FXG graphic?  It is, after all, a major piece of the new hotness that is Flex 4.</p>
<p class="bottom">First, we need to modify the <code>mouseDownHandler</code> to instantiate our FXG graphic.  Then we just add it as the forth parameter to the <code>DragManager.doDrag()</code> call.</p>

<div class="wp_syntax"><div class="code"><pre class="actionscript" style="font-family:monospace;"><span style="color: #0066CC;">private</span> <span style="color: #000000; font-weight: bold;">function</span> mouseDownHandler<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>
    <span style="color: #000000; font-weight: bold;">var</span> star:Star = <span style="color: #000000; font-weight: bold;">new</span> Star<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>;
    DragManager.<span style="color: #006600;">doDrag</span><span style="color: #66cc66;">&#40;</span><span style="color: #0066CC;">e</span>.<span style="color: #006600;">currentTarget</span> as IUIComponent, <span style="color: #000000; font-weight: bold;">null</span>, <span style="color: #0066CC;">e</span>, star<span style="color: #66cc66;">&#41;</span>;
<span style="color: #66cc66;">&#125;</span></pre></div></div>

<p class="bottom">And here is <code>Star.mxml</code>:</p>

<div class="wp_syntax"><div class="code"><pre class="mxml" style="font-family:monospace;"><span style="color: #000000;">&lt;?xml version=<span style="color: #ff0000;">&quot;1.0&quot;</span> encoding=<span style="color: #ff0000;">&quot;utf-8&quot;</span>?<span style="color: #7400FF;">&gt;</span></span>
<span style="color: #000000;"><span style="color: #7400FF;">&lt;s:Graphic</span></span>
<span style="color: #000000;">        xmlns:fx=<span style="color: #ff0000;">&quot;http://ns.adobe.com/mxml/2009&quot;</span></span>
<span style="color: #000000;">        xmlns:s=<span style="color: #ff0000;">&quot;library://ns.adobe.com/flex/spark&quot;</span></span>
<span style="color: #000000;">        width=<span style="color: #ff0000;">&quot;80&quot;</span> height=<span style="color: #ff0000;">&quot;80&quot;</span><span style="color: #7400FF;">&gt;</span></span>
&nbsp;
    <span style="color: #000000;"><span style="color: #7400FF;">&lt;s:Path</span> data=<span style="color: #ff0000;">&quot;M 119,0 L 148,86 238,86 166,140 192,226 119,175 46,226 72,140 0,86 90,86 Z&quot;</span></span>
<span style="color: #000000;">            y=<span style="color: #ff0000;">&quot;2&quot;</span> scaleX=<span style="color: #ff0000;">&quot;0.3361345&quot;</span> scaleY=<span style="color: #ff0000;">&quot;0.3361345&quot;</span><span style="color: #7400FF;">&gt;</span></span>
        <span style="color: #000000;"><span style="color: #7400FF;">&lt;s:fill</span><span style="color: #7400FF;">&gt;</span></span>
            <span style="color: #000000;"><span style="color: #7400FF;">&lt;mx:SolidColor</span> color=<span style="color: #ff0000;">&quot;#FFCC00&quot;</span> <span style="color: #7400FF;">/&gt;</span></span>
        <span style="color: #000000;"><span style="color: #7400FF;">&lt;/s:fill</span><span style="color: #7400FF;">&gt;</span></span>
    <span style="color: #000000;"><span style="color: #7400FF;">&lt;/s:Path</span><span style="color: #7400FF;">&gt;</span></span>
<span style="color: #000000;"><span style="color: #7400FF;">&lt;/s:Graphic</span><span style="color: #7400FF;">&gt;</span></span></pre></div></div>

<p class="bottom">Bang!  We have a gold star as our drag proxy.  Try it out for yourself (view source enabled):</p>
<div id="flashcontent-drag-drop-star">
Flash is required.  <a href="http://www.adobe.com/go/getflashplayer">Get it here!</a>
</div>
<h5>Dynamic Drag Proxy</h5>
<p>Dragging a gold star is pretty cool, but how can we make the drag proxy look <b>exactly</b> like the drag source?  For that we need a dynamic drag proxy.</p>
<p class="bottom">First, for reasons which will become clear in a moment, we need to revise our app to make each of the drag source graphics into a separate component.  So the left <code>Panel</code> changes to contain these custom components:</p>

<div class="wp_syntax"><div class="code"><pre class="mxml" style="font-family:monospace;"><span style="color: #000000;"><span style="color: #7400FF;">&lt;s:Panel</span> title=<span style="color: #ff0000;">&quot;src&quot;</span> width=<span style="color: #ff0000;">&quot;100&quot;</span> minHeight=<span style="color: #ff0000;">&quot;133&quot;</span> x=<span style="color: #ff0000;">&quot;10&quot;</span> y=<span style="color: #ff0000;">&quot;10&quot;</span><span style="color: #7400FF;">&gt;</span></span>
    <span style="color: #000000;"><span style="color: #7400FF;">&lt;graphics:Square</span> fillColor=<span style="color: #ff0000;">&quot;#6666FF&quot;</span></span>
<span style="color: #000000;">            mouseDown=<span style="color: #ff0000;">&quot;mouseDownHandler(event)&quot;</span> <span style="color: #7400FF;">/&gt;</span></span>
&nbsp;
    <span style="color: #000000;"><span style="color: #7400FF;">&lt;graphics:Circle</span> fillColor=<span style="color: #ff0000;">&quot;#FF66FF&quot;</span></span>
<span style="color: #000000;">            mouseDown=<span style="color: #ff0000;">&quot;mouseDownHandler(event)&quot;</span> <span style="color: #7400FF;">/&gt;</span></span>
&nbsp;
    <span style="color: #000000;"><span style="color: #7400FF;">&lt;graphics:Star</span> fillColor=<span style="color: #ff0000;">&quot;#FFCC00&quot;</span></span>
<span style="color: #000000;">            mouseDown=<span style="color: #ff0000;">&quot;mouseDownHandler(event)&quot;</span> <span style="color: #7400FF;">/&gt;</span></span>
&nbsp;
    <span style="color: #000000;"><span style="color: #7400FF;">&lt;graphics:Square</span> fillColor=<span style="color: #ff0000;">&quot;#66FF99&quot;</span></span>
<span style="color: #000000;">            mouseDown=<span style="color: #ff0000;">&quot;mouseDownHandler(event)&quot;</span> <span style="color: #7400FF;">/&gt;</span></span>
&nbsp;
    <span style="color: #000000;"><span style="color: #7400FF;">&lt;s:layout</span><span style="color: #7400FF;">&gt;</span></span>
        <span style="color: #000000;"><span style="color: #7400FF;">&lt;s:VerticalLayout</span> gap=<span style="color: #ff0000;">&quot;10&quot;</span> horizontalAlign=<span style="color: #ff0000;">&quot;center&quot;</span> paddingTop=<span style="color: #ff0000;">&quot;10&quot;</span> paddingBottom=<span style="color: #ff0000;">&quot;10&quot;</span> <span style="color: #7400FF;">/&gt;</span></span>
    <span style="color: #000000;"><span style="color: #7400FF;">&lt;/s:layout</span><span style="color: #7400FF;">&gt;</span></span>
<span style="color: #000000;"><span style="color: #7400FF;">&lt;/s:Panel</span><span style="color: #7400FF;">&gt;</span></span></pre></div></div>

<p class="bottom">Next, we again modify the <code>mouseDownHandler</code>, this time we instantiate our drag proxy dynamically.  We use reflection on the incoming drag source to get its name, instantiate it, adjust a few properties, and pass it to the <code>DragManager.doDrag()</code> call.</p>

<div class="wp_syntax"><div class="code"><pre class="actionscript" style="font-family:monospace;"><span style="color: #0066CC;">private</span> <span style="color: #000000; font-weight: bold;">function</span> mouseDownHandler<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>
    <span style="color: #000000; font-weight: bold;">var</span> dragSrc:Graphic = <span style="color: #0066CC;">e</span>.<span style="color: #006600;">currentTarget</span> as Graphic;
&nbsp;
    <span style="color: #808080; font-style: italic;">//create a proxy by creating a new &quot;copy&quot; of the drag src</span>
    <span style="color: #000000; font-weight: bold;">var</span> className:<span style="color: #0066CC;">String</span> = getQualifiedClassName<span style="color: #66cc66;">&#40;</span>dragSrc<span style="color: #66cc66;">&#41;</span>;
    <span style="color: #000000; font-weight: bold;">var</span> klass:<span style="color: #000000; font-weight: bold;">Class</span> = getDefinitionByName<span style="color: #66cc66;">&#40;</span>className<span style="color: #66cc66;">&#41;</span> as <span style="color: #000000; font-weight: bold;">Class</span>;
    <span style="color: #000000; font-weight: bold;">var</span> proxy:<span style="color: #66cc66;">*</span> = <span style="color: #000000; font-weight: bold;">new</span> klass<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>;
&nbsp;
    <span style="color: #808080; font-style: italic;">//set the proxy's properties to match the src + sexy drop shadow</span>
    proxy.<span style="color: #0066CC;">width</span> = dragSrc.<span style="color: #0066CC;">width</span>;
    proxy.<span style="color: #0066CC;">height</span> = dragSrc.<span style="color: #0066CC;">height</span>;
    proxy.<span style="color: #006600;">fillColor</span> = <span style="color: #66cc66;">&#40;</span>dragSrc as IDraggableGraphic<span style="color: #66cc66;">&#41;</span>.<span style="color: #006600;">fillColor</span>;
    proxy.<span style="color: #006600;">filters</span> = <span style="color: #66cc66;">&#91;</span><span style="color: #000000; font-weight: bold;">new</span> DropShadowFilter<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#93;</span>;
&nbsp;
    DragManager.<span style="color: #006600;">doDrag</span><span style="color: #66cc66;">&#40;</span>dragSrc, <span style="color: #000000; font-weight: bold;">null</span>, <span style="color: #0066CC;">e</span>, proxy<span style="color: #66cc66;">&#41;</span>;
<span style="color: #66cc66;">&#125;</span></pre></div></div>

<p>The real reason for the reflection gymnastics, plus the need to package each drag source as a custom component, is the lack of a <b>deep copy</b> operation on <code>UIComponent</code>.  If we could just <i>clone</i> the drag source, we&#8217;d be golden.  Alas, for many reasons, the most obvious of which is that it is a huge pain in the ass, there is no such thing as deep copy.  In our case, my work around was to package all the visual stuff of each draggable item into a single custom component with a known API (all the custom graphics implement <code>IDraggableGraphic</code>).  Then I reflect, instantiate, configure, and pass to <code>doDrag()</code>.</p>
<p class="bottom">Our dynamic drag proxy now matches the drag source, plus the sexy drop shadow.  Check it out (view source enabled):</p>
<div id="flashcontent-drag-drop-proxy">
Flash is required.  <a href="http://www.adobe.com/go/getflashplayer">Get it here!</a>
</div>
<h5>Files</h5>
<ul>
<li><a href="http://saturnboy.com/proj/flex4/drag_drop/simple/DragDrop.html">DragDrop</a> (<a href="http://saturnboy.com/proj/flex4/drag_drop/simple/srcview/DragDrop.zip">download</a>)</li>
<li><a href="http://saturnboy.com/proj/flex4/drag_drop/star/DragDropStar.html">DragDropStar</a> (<a href="http://saturnboy.com/proj/flex4/drag_drop/star/srcview/DragDropStar.zip">download</a>)</li>
<li><a href="http://saturnboy.com/proj/flex4/drag_drop/proxy/DragDropProxy.html">DragDropProxy</a> (<a href="http://saturnboy.com/proj/flex4/drag_drop/proxy/srcview/DragDropProxy.zip">download</a>)</li>
</ul>
<blockquote><p><b>NOTE:</b> All code was built with Flash Builder 4 Beta 1.</p></blockquote>
<div>
<script type="text/javascript">
swfobject.embedSWF('http://saturnboy.com/proj/flex4/drag_drop/simple/DragDrop.swf', 'flashcontent-drag-drop', '400', '260', '10.0.0', 'expressInstall.swf', false, { bgColor:'#ffffff', base:'.' });
</script><br />
<script type="text/javascript">
swfobject.embedSWF('http://saturnboy.com/proj/flex4/drag_drop/star/DragDropStar.swf', 'flashcontent-drag-drop-star', '400', '260', '10.0.0', 'expressInstall.swf', false, { bgColor:'#ffffff', base:'.' });
</script><br />
<script type="text/javascript">
swfobject.embedSWF('http://saturnboy.com/proj/flex4/drag_drop/proxy/DragDropProxy.swf', 'flashcontent-drag-drop-proxy', '400', '450', '10.0.0', 'expressInstall.swf', false, { bgColor:'#ffffff', base:'.' });
</script></div>
]]></content:encoded>
			<wfw:commentRss>http://saturnboy.com/2009/08/drag-and-drop-flex-4/feed/</wfw:commentRss>
		<slash:comments>21</slash:comments>
		</item>
	</channel>
</rss>

