<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0">
  <channel>
    <title>SnippetRepoBrowser</title>
    <link>http://snippet.gnstudio.com/snippetrepobrowser/index</link>    
    <description>RSS Feed of SnippetRepoBrowser (Global RSS)</description>    
    <language>en-us</language>
    <pubDate>Thu, 09 Feb 2012 21:05:12 +0100</pubDate>
    <docs>SnippetRepoBrowser/index</docs>
    <generator>SnippetRepoBrowser Feed Generator</generator>
    <item>
      <title><![CDATA[How to use SmartDragManager class included in Nabiro]]></title>
      <link>http://snippet.gnstudio.com/viewtopic/34</link>
      <description><![CDATA[This is a sample application that shows you how simple is add and remove drag and drop functionalities to any DisplayObject component using Nabiro&#39;s SmartDragManager class.<br />Note that you need Nabiro 0.950 or major<br />]]><![CDATA[<div class="divcode"><pre class="prettyprint">&lt;?xml version=&quot;1.0&quot; encoding=&quot;utf-8&quot;?&gt;<br />&lt;mx:Application <br />	creationComplete=&quot;addDrag()&quot;<br />	xmlns:mx=&quot;<a href="http://www.adobe.com/2006/mxml&quot;" target="_blank"><a href="http://www.adobe.com/2006/mxml&quot;" target="_blank">http://www.adobe.com/2006/mxml&quot;</a></a> layout=&quot;absolute&quot;&gt;<br />	<br />	&lt;mx:Script&gt;<br />		&lt;![CDATA[<br />		<br />			import mx.events.DragEvent;<br />			import com.gnstudio.nabiro.utilities.SmartDragManager;<br />			<br />			<br />			<br />			<br />			private function onChange(e:Event):void{<br />			<br />				if(e.currentTarget.selected == true){<br />					<br />					addDrag()<br />					<br />				}else{<br />					<br />					removeDrag()<br />					<br />				}<br />			<br />			}<br />			<br />			private function addDrag():void{<br />				<br />				SmartDragManager.makeDraggable(myImage);//make the image on the left draggable<br />				SmartDragManager.makeDraggable(myImage2,false);//make the image on the right draggable without the proxy image<br />				SmartDragManager.makeDroppable(myContainer,onDrop);//make the container droppable<br />					<br />			}<br />			<br />			private function removeDrag():void{<br />				<br />				SmartDragManager.removeDrag(myImage);//remove the drag<br />				SmartDragManager.removeDrag(myImage2);//remove the drag<br />				SmartDragManager.removeDrop(myContainer);//remove the drop<br />				<br />			}<br />			<br />			private function onDrop(e:DragEvent):void{<br />				<br />				var obj:Object = e.dragSource.dataForFormat(&#39;item&#39;);<br />				<br />				var bitmapData:BitmapData = new BitmapData(obj.width, obj.height, true, 0x00000000);<br />	   			bitmapData.draw(obj as IBitmapDrawable);<br />	<br />	            var bitmap:Bitmap = new Bitmap(bitmapData);<br />	<br />				var img:Image = new Image();<br />				img.source = bitmap;<br />				<br />				myContainer.addChild(img);<br />			<br />			}<br />			<br />		]]&gt;<br />	&lt;/mx:Script&gt;<br />	<br /><br />	&lt;mx:HBox horizontalCenter=&quot;0&quot;&gt;<br />	<br />		&lt;mx:Image <br />			toolTip=&quot;Drag Me&quot;<br />			id=&quot;myImage&quot; <br />			source=&quot;assets/nabiro_logo-1.png&quot; <br />			/&gt;<br />		&lt;mx:Image <br />			toolTip=&quot;Drag Me&quot;<br />			id=&quot;myImage2&quot; <br />			source=&quot;assets/nabiro_logo-1.png&quot; <br />			/&gt;<br />		<br />	&lt;/mx:HBox&gt;	<br />	<br />	&lt;mx:CheckBox <br />		label=&quot;Enable Drag&quot;  <br />		horizontalCenter=&quot;0&quot;<br />		y=&quot;130&quot;<br />		selected=&quot;true&quot;<br />		change=&quot;onChange(event)&quot; <br />		/&gt;<br />	<br />	<br />	&lt;mx:Panel <br />		id=&quot;myContainer&quot; <br />		title=&quot;Drop Nabiro logo here&quot; <br />		horizontalCenter=&quot;0&quot;<br />		y=&quot;150&quot; <br />		width=&quot;500&quot; <br />		height=&quot;250&quot; <br />		/&gt;<br />		<br />		<br />&lt;/mx:Application&gt;<br /></pre></div><br /><br />]]></description>
      <author>fedele.marotti</author>
      <pubDate>Fri, 09 Oct 2009 10:53:33 +0200</pubDate>
      <category>Flex 3.x</category>
      <guid>http://snippet.gnstudio.com/viewtopic/34</guid>
   </item>
  </channel>
</rss>
