<?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 20:57:15 +0100</pubDate>
    <docs>SnippetRepoBrowser/index</docs>
    <generator>SnippetRepoBrowser Feed Generator</generator>
    <item>
      <title><![CDATA[Add a custom StatusBar to a WindowedApplication]]></title>
      <link>http://snippet.gnstudio.com/viewtopic/85</link>
      <description><![CDATA[To use a custom component as a statusbar it&#39;s quiet easy,<br />just create your component using MXML or Actionscript, it&#39;s the same, and the add this line to your WindowedApplication<br />]]><![CDATA[<div class="divcode"><pre class="prettyprint">statusBarFactory=&quot;{new ClassFactory(MyCustomStatusBar)}&quot;</pre></div><br /><br />]]></description>
      <author>fedele.marotti</author>
      <pubDate>Thu, 11 Feb 2010 18:02:11 +0100</pubDate>
      <category>Air</category>
      <guid>http://snippet.gnstudio.com/viewtopic/85</guid>
   </item><item>
      <title><![CDATA[Flex SDK 3.5 ComboBox issue]]></title>
      <link>http://snippet.gnstudio.com/viewtopic/84</link>
      <description><![CDATA[In the Flex SDK 3.5.0.12683 the ComboBox Class has a strange behavior, if you change the dataprovider after you have played with your ComboBox, the list of item in the dropdown is not refreshed.<br />Possible solutions to the problem are :<br />1) Switch back to the 3.4 SDK<br />2) Add the following few lines of code after updating the dataprovider : myComboBox.dropdown.dataProvider = yourArray;<br />Enjoy : )<br />]]><![CDATA[<div class="divcode"><pre class="prettyprint">myComboBox.dropdown.dataProvider = yourArray</pre></div><br /><br />]]></description>
      <author>fedele.marotti</author>
      <pubDate>Tue, 09 Feb 2010 16:36:04 +0100</pubDate>
      <category>Flex 3.x</category>
      <guid>http://snippet.gnstudio.com/viewtopic/84</guid>
   </item><item>
      <title><![CDATA[Extending a custom component]]></title>
      <link>http://snippet.gnstudio.com/viewtopic/83</link>
      <description><![CDATA[If you are trying to extend a custom component and you get the following error<br /><br />&quot;Multiple sets of visual children have been specified for this component (base component definition and derived component definition).&quot;<br /><br />the problem is that you have created an MXML component with some children hardcoded;<br /><br />Surfing the net I&#39;ve found an interesting discussion <a href="http://www.tink.ws/blog/extending-your-own-mxml-components/" target="_blank">here</a> but the solution provided there hasn&#39;t convinced me at all.<br /><br />After some attempts I&#39;ve finally found a nice solution that is not to hardcode components inside the MXML but create components using actionscript and then add them to the displayList in the createChildren method.<br />]]><![CDATA[<div class="divcode"><pre class="prettyprint">override protected function childrenCreated():void{<br />	<br />	super.childrenCreated();<br />	<br />	if(!btn){<br />	<br />		btn = new Button();<br />		btn.label = &quot;my as button&quot;;<br />		addChild(btn);<br />	<br />	}<br /><br />}</pre></div><br /><br />]]></description>
      <author>fedele.marotti</author>
      <pubDate>Mon, 08 Feb 2010 17:45:59 +0100</pubDate>
      <category>Flex 3.x</category>
      <guid>http://snippet.gnstudio.com/viewtopic/83</guid>
   </item><item>
      <title><![CDATA[Create a BitmapData from an asset embedded inside an SWF]]></title>
      <link>http://snippet.gnstudio.com/viewtopic/61</link>
      <description><![CDATA[The goal of this snippet is to create a BitmapData from an assets (for example a MovieClip) stored inside an SWF library created using Flash and loaded through CSS;<br />]]><![CDATA[<div class="divcode"><pre class="prettyprint">//CSS FILE<br />.myComponentStylName {<br /><br />   	backgroundImage : Embed(source=&quot;library.swf&quot;, symbol=&quot;MyMovieClip&quot;);<br /><br />}<br /><br />//ActionScript Code<br /><br />var BackgroundImage:Class = getStyle(&quot;backgroundImage&quot;);<br />           <br />var backgroundImageAsset:SpriteAsset = SpriteAsset(new BackgroundImage());<br /><br />var bitmapData = new BitmapData(backgroundImageAsset.width, backgroundImageAsset.height);<br /><br />var matrix:Matrix = new Matrix();<br /><br />bitmapData.draw(ImageSnapshot.captureBitmapData(backgroundImageAsset),matrix);<br /><br /></pre></div><br /><br />]]></description>
      <author>fedele.marotti</author>
      <pubDate>Sat, 21 Nov 2009 14:49:25 +0100</pubDate>
      <category>Flex 3.x</category>
      <guid>http://snippet.gnstudio.com/viewtopic/61</guid>
   </item><item>
      <title><![CDATA[Create a list without the selector indicator]]></title>
      <link>http://snippet.gnstudio.com/viewtopic/60</link>
      <description><![CDATA[The purpuse of this snippet is to create a list and avoid that the selected item remains highlighted<br />]]><![CDATA[<div class="divcode"><pre class="prettyprint">package <br />{<br />	import flash.display.Graphics;<br />	import flash.display.Sprite;<br />	<br />	import mx.controls.List;<br />	import mx.controls.listClasses.IListItemRenderer;<br /><br />	public class ListWithoutSelectionIndicator extends List<br />	{<br />		public function ListWithoutSelectionIndicator()<br />		{<br />			super();<br />		}<br />		override protected function drawSelectionIndicator(indicator:Sprite, x:Number,y:Number, width:Number, height:Number, color:uint,itemRenderer:IListItemRenderer):void{<br />	      <br />	      //this function doesn&#39;t do anything in order to prevent the draw of the selection indicator<br />	      <br />	   	}<br />	}<br />}</pre></div><br /><br />]]></description>
      <author>fedele.marotti</author>
      <pubDate>Fri, 20 Nov 2009 13:12:42 +0100</pubDate>
      <category>Flex 3.x</category>
      <guid>http://snippet.gnstudio.com/viewtopic/60</guid>
   </item><item>
      <title><![CDATA[Skin the TitleWindow]]></title>
      <link>http://snippet.gnstudio.com/viewtopic/59</link>
      <description><![CDATA[The following example shows you how to extends the ProgrammaticSkin and<br />add a gradient as background to a TitleWindow<br />usage : <br />WindowedApplication {<br />    <br />    TitleWindow: ClassReference(&quot;com.gnstudio.skins.TitleWindowSkin&quot;);<br />        <br />}<br />]]><![CDATA[<div class="divcode"><pre class="prettyprint">package com.gnstudio.skins<br />{<br /><br />    import flash.display.GradientType;<br />    import flash.display.InterpolationMethod;<br />    import flash.display.SpreadMethod;<br />    import flash.geom.Matrix;<br />    <br />    import mx.graphics.RectangularDropShadow;<br />    import mx.skins.RectangularBorder;<br /><br />    public class TitleWindowSkin extends RectangularBorder{<br /><br />        <br />       	private var cornerRadius:Number = 6;<br />	private var borderColor:uint = 0xFFFFFF;<br />	private var borderThickness:Number = 1;<br />        <br />        override protected function updateDisplayList (unscaledWidth:Number, unscaledHeight:Number):void{<br />        	<br />            super.updateDisplayList(unscaledWidth, unscaledHeight);<br />            <br />            graphics.clear()<br />            <br />            if(getStyle(&quot;cornerRadius&quot;)){<br />          	<br />          	cornerRadius = getStyle(&quot;cornerRadius&quot;);<br />            <br />            }<br />            if(getStyle(&quot;borderColor&quot;)){<br />          	<br />          	borderColor = getStyle(&quot;borderColor&quot;);<br />            <br />            }<br />            if(getStyle(&quot;borderThickness&quot;)){<br />          	<br />          	borderThickness = getStyle(&quot;borderThickness&quot;);<br />            <br />            }<br />			<br />            var fillType:String = GradientType.LINEAR;<br />            var colors:Array = [0x000000,0x111111,0x333333];<br />            var alphas:Array = [1,.75, .50];<br />            var ratios:Array = [0,128, 255];<br />            var matrix:Matrix = new Matrix();<br />            matrix.createGradientBox(unscaledWidth,unscaledHeight*2, Math.PI/2, 0, 0);<br />            var spreadMethod:String = SpreadMethod.REPEAT;<br />            var interpolationMethod:String = InterpolationMethod.LINEAR_RGB;<br />			<br />            graphics.lineStyle(borderThickness, borderColor);<br />            graphics.beginGradientFill(fillType, colors, alphas, ratios, matrix, spreadMethod,interpolationMethod);<br />			<br />            graphics.drawRoundRectComplex(0,0,unscaledWidth,unscaledHeight,cornerRadius,cornerRadius,cornerRadiu<br /><br />s,cornerRadius);<br /><br />        }<br /><br />    }<br />}<br /></pre></div><br /><br />]]></description>
      <author>fedele.marotti</author>
      <pubDate>Fri, 20 Nov 2009 12:58:40 +0100</pubDate>
      <category>Flex 3.x</category>
      <guid>http://snippet.gnstudio.com/viewtopic/59</guid>
   </item><item>
      <title><![CDATA[Skin the WindowedApplication]]></title>
      <link>http://snippet.gnstudio.com/viewtopic/58</link>
      <description><![CDATA[The following example shows you how to extends the ProgrammaticSkin and add an image as background of your WindowedApplication positioned at the center of the window;<br />usage : <br />WindowedApplication {<br />    <br />    borderSkin: ClassReference(&quot;com.gnstudio.skins.ApplicationSkin&quot;);<br />        <br />}<br />]]><![CDATA[<div class="divcode"><pre class="prettyprint">package com.gnstudio.skins<br />{<br />	import flash.display.Bitmap;<br />	import flash.display.BitmapData;<br />	import flash.events.Event;<br />	import flash.geom.Matrix;<br />	import flash.geom.Point;<br />	import flash.geom.Rectangle;<br />	<br />	import mx.controls.Image;<br />	import mx.skins.ProgrammaticSkin;<br /><br />	public class ApplicationSkin extends ProgrammaticSkin{<br />		<br />		[Embed(source=&quot;skin/application/bckg.jpg&quot;)]<br />		private var imageClass:Class<br />		<br />		private var _image:Bitmap;<br />		private var _bitmapData:BitmapData;<br />		<br />		override protected function updateDisplayList(unscaledWidth:Number, unscaledHeight:Number):void{<br />        	<br />			super.updateDisplayList(unscaledWidth, unscaledHeight);<br />            <br />          		var backgroundColor:uint = getStyle(&quot;backgroundColor&quot;);<br />           <br />			if(!_image){<br />            	<br />				_image = new imageClass()<br />            			_bitmapData = new BitmapData(_image.width, _image.height);<br />				var matrix:Matrix = new Matrix();<br />				_bitmapData.draw(_image,matrix);   <br />            	<br />			}<br />           <br />            <br /> 			if(unscaledWidth &amp;&amp; unscaledWidth){<br />        		<br /> 				graphics.clear();<br />				graphics.beginFill(backgroundColor);<br />				graphics.drawRect(0, 0, unscaledWidth,unscaledHeight);<br />				graphics.endFill();<br />   				<br />				var x:Number = unscaledWidth/2 - _bitmapData.width/2;<br />				var y:Number = unscaledHeight/2 - _bitmapData.height/2;<br />				var bd:BitmapData = new BitmapData(unscaledWidth,unscaledHeight,true,backgroundColor);<br />				bd.copyPixels(_bitmapData,new Rectangle(0,0,_bitmapData.width,_bitmapData.height),new Point(x,y));<br />				graphics.beginBitmapFill(bd, new Matrix(), false, true);<br />				graphics.drawRect(x, y, _bitmapData.width, _bitmapData.height);<br />   					<br />			}<br />        	 	<br />		}<br />       	<br />	}<br />}</pre></div><br /><br />]]></description>
      <author>fedele.marotti</author>
      <pubDate>Fri, 20 Nov 2009 12:23:26 +0100</pubDate>
      <category>Air</category>
      <guid>http://snippet.gnstudio.com/viewtopic/58</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 class="prettyprint">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 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>
