<?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:01:40 +0100</pubDate>
    <docs>SnippetRepoBrowser/index</docs>
    <generator>SnippetRepoBrowser Feed Generator</generator>
    <item>
      <title><![CDATA[Manage bitmap output levels]]></title>
      <link>http://snippet.gnstudio.com/viewtopic/49</link>
      <description><![CDATA[Imagine to want to reach the same effect of the <a href="http://www.zuberphotographics.com/content/photoshop/levels-output.htm" target="_blank">output levels</a> panel you have in Photoshop through ActionScript, you can get the result by remaping the color channel values in an image that has up to four arrays of color palette data, one for each channel.<br /><img alt="" src="http://www.zuberphotographics.com/images/1420i.gif" border="0" /><br />In order to do this you can simply use the <a href="http://help.adobe.com/en_US/AS3LCR/Flash_10.0/flash/display/BitmapData.html#paletteMap%28%29" target="_blank">paletteMap()</a> method of the BitmapData and recalculate the values for each channel to use inside the method accordingly to 2 different points (black and white).<br />Download the last release of nabiro to get the class that do the job for you.<br />]]><![CDATA[<div class="divcode"><pre lang="actionscript">&lt;mx:Application 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 />			import com.gnstudio.nabiro.ui.images.utils.OutputLevels;<br />			import mx.events.SliderEvent;<br />			<br />			private var bmd:BitmapData;<br />			<br />			override protected function childrenCreated():void{<br />				<br />				super.childrenCreated();<br />				<br />				var url:URLRequest = new URLRequest(&quot;central_park.jpg&quot;)<br />				<br />				var loader:Loader = new Loader();<br />				loader.contentLoaderInfo.addEventListener(Event.COMPLETE, imageCompleted);<br />				<br />				loader.load(url);<br />				<br />			}<br />			<br />			<br />			private function imageCompleted(e:Event):void{<br />				<br />				e.target.removeEventListener(e.type, arguments.callee);<br />				<br />				bmd = Bitmap(e.currentTarget.content).bitmapData;<br />				<br />				var output:OutputLevels = new OutputLevels(100);<br />				image.source = new Bitmap(output.setLevels(bmd.clone(), 0, 200));<br />				<br />			}<br />			<br />			private function outputLevels(e:SliderEvent):void{<br />				<br />				var output:OutputLevels = new OutputLevels(e.target.values[0] + (e.target.values[1] - e.target.values[0]) / 2);<br />				image.source = new Bitmap(output.setLevels(bmd.clone(), e.target.values[0], e.target.values[1]));<br />				<br />			}<br />			<br />		]]&gt;<br />	&lt;/mx:Script&gt;<br />	<br />	&lt;mx:Image id=&quot;image&quot; verticalAlign=&quot;middle&quot; complete=&quot;imageCompleted(event)&quot; horizontalAlign=&quot;center&quot;  left=&quot;30&quot; right=&quot;30&quot; top=&quot;30&quot; bottom=&quot;30&quot;/&gt;<br />	&lt;mx:HSlider bottom=&quot;5&quot; right=&quot;30&quot; left=&quot;30&quot; minimum=&quot;0&quot; maximum=&quot;255&quot; thumbCount=&quot;2&quot; values=&quot;[0, 255]&quot; liveDragging=&quot;false&quot; change=&quot;outputLevels(event)&quot; /&gt;</pre></div><br /><br />]]></description>
      <author>Giorgio Natili</author>
      <pubDate>Mon, 09 Nov 2009 05:35:07 +0100</pubDate>
      <category>ActionScript</category>
      <guid>http://snippet.gnstudio.com/viewtopic/49</guid>
   </item><item>
      <title><![CDATA[Retrive image type, width and height of png, jpg, gif using nabiro]]></title>
      <link>http://snippet.gnstudio.com/viewtopic/44</link>
      <description><![CDATA[With these few lines of code you can easly retrive type and size of an image<br />]]><![CDATA[<div class="divcode"><pre lang="actionscript">var imageInfo:ImageInfo = new ImageInfo(myByteArray);<br />imageInfo.extractType();<br />imageInfo.extractSize();<br />trace(imageInfo.type.toString());<br />trace(imageInfo.width.toString());<br />trace(imageInfo.height.toString());</pre></div><br /><br />]]></description>
      <author>fedele.marotti</author>
      <pubDate>Wed, 28 Oct 2009 18:44:28 +0100</pubDate>
      <category>Flex 3.x</category>
      <guid>http://snippet.gnstudio.com/viewtopic/44</guid>
   </item><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 lang="actionscript">&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><item>
      <title><![CDATA[Dispatch events between native windows]]></title>
      <link>http://snippet.gnstudio.com/viewtopic/19</link>
      <description><![CDATA[I was looking to a way to dispatch events between ultiple windows in an AIR application and, after I found on google only some solution that state to send a reference of the target for the event to the new window uing public properties, I came out with a more elegant solution that involves a new class added to nabiro.<br />The idea is that this class acts like a bridge on which is possible to register a DisplayObjetc for a specific message (i.e. the event type), the snippet represent only the simple usage of thebridge for register a new DisplayObject, attached there is the complete sample.<br />]]><![CDATA[<div class="divcode"><pre lang="actionscript">bridge = WindowsBridge.getInstance();<br />bridge.register(this, &quot;Test&quot;);<br />				<br />addEventListener(&quot;Test&quot;, onTest);<br /><br />// Window dispatch code<br />var test:WindowsBridge = WindowsBridge.getInstance();<br />					<br />test.dispatchEvent(new IntraWinComEvent(IntraWinComEvent.DEFAULT, new Event(&quot;Test&quot;)));</pre></div><br /><br />]]></description>
      <author>Giorgio Natili</author>
      <pubDate>Sun, 20 Sep 2009 20:00:29 +0200</pubDate>
      <category>Air</category>
      <guid>http://snippet.gnstudio.com/viewtopic/19</guid>
   </item>
  </channel>
</rss>
