<?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>Easy Flex &#187; drag and drop</title>
	<atom:link href="http://evtimmy.com/category/drag-and-drop/feed/" rel="self" type="application/rss+xml" />
	<link>http://evtimmy.com</link>
	<description>Evtim on Flex SDK</description>
	<lastBuildDate>Thu, 03 Nov 2011 07:18:58 +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 Skinning in Spark</title>
		<link>http://evtimmy.com/2010/01/drag-and-drop-skinning-in-spark/</link>
		<comments>http://evtimmy.com/2010/01/drag-and-drop-skinning-in-spark/#comments</comments>
		<pubDate>Tue, 19 Jan 2010 06:16:04 +0000</pubDate>
		<dc:creator>Evtim</dc:creator>
				<category><![CDATA[drag and drop]]></category>
		<category><![CDATA[skinning]]></category>

		<guid isPermaLink="false">http://evtimmy.com/?p=198</guid>
		<description><![CDATA[Customize the ItemRenderer&#8216;s &#8220;dragging&#8221; state.  The drag indicator is the image that the user sees when they select and item and drag it away from the source container. By default the Spark List creates a drag indicator by duplicating all the ItemRenderers for the items being dragged. Therefore a natural way to customize the drag [...]]]></description>
			<content:encoded><![CDATA[<p><a href="http://evtimmy.com/wordpress/wp-content/uploads/2010/01/dndlistskinning.swf"><img class="alignleft size-thumbnail wp-image-199" title="dndlistskinning" src="http://evtimmy.com/wordpress/wp-content/uploads/2010/01/dndlistskinning-150x150.png" alt="dndlistskinning" width="150" height="150" /></a></p>
<p><span style="color: #ff6600;">Customize the <em>ItemRenderer</em>&#8216;s &#8220;<em>dragging</em>&#8221; state</span>.  The <em>drag indicator</em> is the image that the user sees when they select and item and drag it away from the source container. By default the Spark List creates a <em>drag indicator</em> by duplicating all the <em>ItemRenderers </em>for the items being dragged. Therefore a natural way to customize the drag indicator is by customizing the <em>ItemRenderer </em>skin. Spark makes that easy by introducing the  optional &#8220;<em>dragging</em>&#8221; state.<br />
<span style="color: #ff6600;">Customize the <em>List</em>&#8216;s optional &#8220;<em>dropIndicator</em>&#8221; skin part</span>.  The <em>drop indicator</em> is the image that the user sees as an indicator of where the dragged items are going to be inserted in the destination container.  By default, the Spark List displays a horizontal/vertical line along the gap between the at the insertion point.  Spark makes that easy by automatically managing the &#8220;<em>dropIndicator</em>&#8221; optional dynamic skin part.</p>
<p><span id="more-198"></span></p>
<h2>Customize the Drag Indicator</h2>
<p>I&#8217;ll set up a custom ItemRenderer and I&#8217;ll flesh out the optional &#8220;dragging&#8221; state.<br />
CustomDraggingItemRenderer.mxml:</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> focusEnabled=<span style="color: #ff0000;">&quot;false&quot;</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;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;normalAndShowsCaret&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;hoveredAndShowsCaret&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;selectedAndShowsCaret&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: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;-1&quot;</span> includeIn=<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:stroke</span><span style="color: #7400FF;">&gt;</span></span>
			<span style="color: #000000;"><span style="color: #7400FF;">&lt;s:SolidColorStroke</span> color=<span style="color: #ff0000;">&quot;0xDDBBCC&quot;</span> weight=<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:stroke</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:SolidColor</span> color=<span style="color: #ff0000;">&quot;0x5010CC&quot;</span> alpha=<span style="color: #ff0000;">&quot;0.3&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:Label</span> id=<span style="color: #ff0000;">&quot;labelDisplay&quot;</span> verticalCenter=<span style="color: #ff0000;">&quot;0&quot;</span> </span>
<span style="color: #000000;">			 left=<span style="color: #ff0000;">&quot;3&quot;</span> right=<span style="color: #ff0000;">&quot;3&quot;</span> top=<span style="color: #ff0000;">&quot;6&quot;</span> bottom=<span style="color: #ff0000;">&quot;4&quot;</span> </span>
<span style="color: #000000;">			 fontWeight.dragging=<span style="color: #ff0000;">&quot;bold&quot;</span><span style="color: #7400FF;">/&gt;</span></span>
&nbsp;
<span style="color: #000000;"><span style="color: #7400FF;">&lt;/s:ItemRenderer</span><span style="color: #7400FF;">&gt;</span></span></pre></div></div>

<p>When the Spark List creates the duplicate ItemRenderes for the drag indicator, it will set them to their &#8220;dragging&#8221; state. Note that at that point the List&#8217;s data item will be rendered by two ItemRender instances &#8211; one to display the item in the List itself and one to display the item in the drag indicator.</p>
<h2>Customize the Drop Indicator</h2>
<p>I&#8217;ll set up a custom List skin. I&#8217;ll replace the &#8220;dropIndicator&#8221; skin part. Note that since the part is a dynamic part (created only during drag-and-drop operation) it&#8217;s placed inside the &lt;fx:Declarations/&gt; tag.<br />
CustomDropIndicatorListSkin.mxml:</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: #808080; font-style: italic;">&lt;!--- </span>
<span style="color: #000000;">          Defines the appearance of the the List's drop indicator.</span>
<span style="color: #000000;">          To customize the drop indicator appearance, create a custom ListSkin class.</span>
<span style="color: #000000;">          The List's layout takes care to size and position the dropIndicator.</span>
<span style="color: #000000;">          The size of the &lt;code&gt;</span></span>dropIndicator<span style="color: #000000;">&lt;/code<span style="color: #7400FF;">&gt;</span></span> is typically set to the size of the 
          gaps between the items.
          The minimum and maximum settings are typically respected only in the direction
          along the major axis (the gap axis).  For example a VerticalLayout ignores the 
          <span style="color: #000000;">&lt;code<span style="color: #7400FF;">&gt;</span></span>minWidth<span style="color: #000000;">&lt;/code<span style="color: #7400FF;">&gt;</span></span> and <span style="color: #000000;">&lt;code<span style="color: #7400FF;">&gt;</span></span>maxWidth<span style="color: #000000;">&lt;/code<span style="color: #7400FF;">&gt;</span></span> settings, 
          but respect <span style="color: #000000;">&lt;code<span style="color: #7400FF;">&gt;</span></span>minHeight<span style="color: #000000;">&lt;/code<span style="color: #7400FF;">&gt;</span></span> and <span style="color: #000000;">&lt;code<span style="color: #7400FF;">&gt;</span></span>maxHeight<span style="color: #000000;">&lt;/code<span style="color: #7400FF;">&gt;</span></span>. 
&nbsp;
          @copy spark.components.List#dropIndicator
    --&gt;
    <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;3&quot;</span> minHeight=<span style="color: #ff0000;">&quot;3&quot;</span> maxWidth=<span style="color: #ff0000;">&quot;3&quot;</span> maxHeight=<span style="color: #ff0000;">&quot;3&quot;</span><span style="color: #7400FF;">&gt;</span></span>
			<span style="color: #000000;"><span style="color: #7400FF;">&lt;s:Line</span> width=<span style="color: #ff0000;">&quot;20&quot;</span> left=<span style="color: #ff0000;">&quot;3&quot;</span> verticalCenter=<span style="color: #ff0000;">&quot;2&quot;</span><span style="color: #7400FF;">&gt;</span></span>
				<span style="color: #000000;"><span style="color: #7400FF;">&lt;s:stroke</span><span style="color: #7400FF;">&gt;</span></span>
					<span style="color: #000000;"><span style="color: #7400FF;">&lt;s:SolidColorStroke</span> color=<span style="color: #ff0000;">&quot;0xFF0000&quot;</span><span style="color: #7400FF;">/&gt;</span></span>
				<span style="color: #000000;"><span style="color: #7400FF;">&lt;/s:stroke</span><span style="color: #7400FF;">&gt;</span></span>
			<span style="color: #000000;"><span style="color: #7400FF;">&lt;/s:Line</span><span style="color: #7400FF;">&gt;</span></span>
&nbsp;
			<span style="color: #000000;"><span style="color: #7400FF;">&lt;s:Path</span> left=<span style="color: #ff0000;">&quot;50&quot;</span> verticalCenter=<span style="color: #ff0000;">&quot;-2&quot;</span> scaleX=<span style="color: #ff0000;">&quot;-1&quot;</span> </span>
<span style="color: #000000;">					data=<span style="color: #ff0000;">&quot;M 0 5 L 30 5 26 0 40 8 26 16 30 11 0 11 Z&quot;</span><span style="color: #7400FF;">&gt;</span></span>
				<span style="color: #000000;"><span style="color: #7400FF;">&lt;s:stroke</span><span style="color: #7400FF;">&gt;</span></span>
					<span style="color: #000000;"><span style="color: #7400FF;">&lt;s:LinearGradientStroke</span> rotation=<span style="color: #ff0000;">&quot;5&quot;</span> weight=<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:GradientEntry</span> color=<span style="color: #ff0000;">&quot;0xD8D8D8&quot;</span><span style="color: #7400FF;">/&gt;</span></span>
						<span style="color: #000000;"><span style="color: #7400FF;">&lt;s:GradientEntry</span> color=<span style="color: #ff0000;">&quot;0x000000&quot;</span><span style="color: #7400FF;">/&gt;</span></span>
					<span style="color: #000000;"><span style="color: #7400FF;">&lt;/s:LinearGradientStroke</span><span style="color: #7400FF;">&gt;</span></span>
				<span style="color: #000000;"><span style="color: #7400FF;">&lt;/s:stroke</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:LinearGradient</span> rotation=<span style="color: #ff0000;">&quot;90&quot;</span><span style="color: #7400FF;">&gt;</span></span>
						<span style="color: #000000;"><span style="color: #7400FF;">&lt;s:GradientEntry</span> color=<span style="color: #ff0000;">&quot;0xD8D8D8&quot;</span> <span style="color: #7400FF;">/&gt;</span></span>
						<span style="color: #000000;"><span style="color: #7400FF;">&lt;s:GradientEntry</span> color=<span style="color: #ff0000;">&quot;0x888888&quot;</span> <span style="color: #7400FF;">/&gt;</span></span>
					<span style="color: #000000;"><span style="color: #7400FF;">&lt;/s:LinearGradient</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: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>Click on the image at the top of the page to see the example in action. The sources are available <a href='http://evtimmy.com/wordpress/wp-content/uploads/2010/01/dndlistskinning.zip'>here</a>. The example was compiled with the Gumbo Flex SDK build 13553.</p>
]]></content:encoded>
			<wfw:commentRss>http://evtimmy.com/2010/01/drag-and-drop-skinning-in-spark/feed/</wfw:commentRss>
		<slash:comments>16</slash:comments>
		</item>
	</channel>
</rss>

