<?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:03:12 +0100</pubDate>
    <docs>SnippetRepoBrowser/index</docs>
    <generator>SnippetRepoBrowser Feed Generator</generator>
    <item>
      <title><![CDATA[Filter messages using the logcat command]]></title>
      <link>http://snippet.gnstudio.com/viewtopic/112</link>
      <description><![CDATA[When working on mobile with AIR you cab use the <a href="http://developer.android.com/guide/developing/tools/logcat.html" target="_blank">logcat tool</a> available in the Andorid SDK to grab information from the device and dumping them via USB on a log screen.<br />If you are interested to get only the trace statements and the ActionScript error messages you can restict the logcat output via command line with the snippet you find below. <br />The reason why you can do this filtering is because during the packaging process each AIR application has the word <span style="font-style:italic">air</span> added to the application ID, therefore using the filter I.air guarantees to dump all messages for the currently running AIR application.<br />The letter <span style="font-style:italic">I</span> stays for the <span style="font-style:italic">Information</span> priority level.<br />]]><![CDATA[<div class="divcode"><pre lang="actionscript">androidSDK/platform-tools/adb logcat|grep &quot;I.air&quot;</pre></div><br /><br />]]></description>
      <author>GiorgioNatili</author>
      <pubDate>Sun, 13 Nov 2011 17:24:57 +0100</pubDate>
      <category>Air</category>
      <guid>http://snippet.gnstudio.com/viewtopic/112</guid>
   </item><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 lang="actionscript">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[AIR Run-Time Font Embedding]]></title>
      <link>http://snippet.gnstudio.com/viewtopic/71</link>
      <description><![CDATA[Load and use embedded fonts at run-time.<br />]]><![CDATA[<div class="divcode"><pre lang="actionscript">/**<br /> * Prepare font bundle SWF with embedded fonts.<br /> */<br />[Embed(source=&#39;../assets/Anonymous Pro B.ttf&#39;, fontName=&#39;AnonymousProB&#39;, fontWeight=&#39;bold&#39;, fontStyle=&#39;normal&#39;, mimeType=&#39;application/x-font&#39;, advancedAntiAliasing=&#39;true&#39;)] <br />public static var AnonymousProB:Class;<br /><br />[Embed(source=&#39;../assets/Anonymous Pro BI.ttf&#39;, fontName=&#39;AnonymousProBI&#39;, fontWeight=&#39;bold&#39;, fontStyle=&#39;italic&#39;, mimeType=&#39;application/x-font&#39;, advancedAntiAliasing=&#39;true&#39;)] <br />public static var AnonymousProBI:Class;<br /><br />[Embed(source=&#39;../assets/Anonymous Pro I.ttf&#39;, fontName=&#39;AnonymousProI&#39;, fontWeight=&#39;normal&#39;, fontStyle=&#39;italic&#39;, mimeType=&#39;application/x-font&#39;, advancedAntiAliasing=&#39;true&#39;)] <br />public static var AnonymousProI:Class;<br /><br />[Embed(source=&#39;../assets/Anonymous Pro.ttf&#39;, fontName=&#39;AnonymousPro&#39;, fontWeight=&#39;normal&#39;, fontStyle=&#39;normal&#39;, mimeType=&#39;application/x-font&#39;, advancedAntiAliasing=&#39;true&#39;)] <br />public static var AnonymousPro:Class;<br /><br />/**<br /> * Load the bundle using Loader.<br /> */<br />protected function loadFonts():void {<br />	<br />	var urlRequest:URLRequest = new URLRequest(&quot;fonts/FontBundle.swf&quot;);<br />	<br />	var loader:Loader = new Loader();<br />	loader.contentLoaderInfo.addEventListener(Event.COMPLETE, onLoaderComplete);<br />	<br />	var loaderContext:LoaderContext = new LoaderContext();<br />	loaderContext.allowLoadBytesCodeExecution = true;<br />	loaderContext.applicationDomain = ApplicationDomain.currentDomain;<br />	<br />	loader.load(urlRequest, loaderContext);<br />	<br />}<br /><br />/**<br /> * Register fonts and render the text field. <br /> */<br />protected function onLoaderComplete(event:Event):void {<br />	<br />	var FontBundle:Class = ApplicationDomain.currentDomain.getDefinition(&quot;FontBundle&quot;) as Class;<br />	<br />	Font.registerFont(FontBundle.AnonymousProB);<br />	Font.registerFont(FontBundle.AnonymousProBI);<br />	Font.registerFont(FontBundle.AnonymousProI);<br />	Font.registerFont(FontBundle.AnonymousPro);<br />	<br />	var AnonymousProBI:Class = FontBundle.AnonymousProBI;<br />	var font:Font = new AnonymousProBI() as Font;<br />	<br />	var textFormat:TextFormat = new TextFormat();<br />	textFormat.font = font.fontName;<br />	textFormat.size = 35;<br />	<br />	var textField:TextField = new TextField();<br />	textField.autoSize = TextFieldAutoSize.LEFT;<br />	textField.defaultTextFormat = textFormat;<br />	textField.antiAliasType = AntiAliasType.ADVANCED;<br />	textField.embedFonts = true;<br />	textField.multiline = true;<br />	textField.rotation = 45;<br />	textField.text = &quot;The quick brown fox jumps over the lazy dog.&quot; + &quot;\n&quot; + new Date().toTimeString();<br />	textField.width = 400;<br />	textField.wordWrap = true;<br />	textField.x = 100;<br />	textField.y = 100;<br />	<br />	addChild(textField);<br />	<br />}</pre></div><br /><br />]]></description>
      <author>ivan.varga</author>
      <pubDate>Wed, 16 Dec 2009 18:38:01 +0100</pubDate>
      <category>Air</category>
      <guid>http://snippet.gnstudio.com/viewtopic/71</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 lang="actionscript">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[File system tree root directory]]></title>
      <link>http://snippet.gnstudio.com/viewtopic/21</link>
      <description><![CDATA[The following example shows how you can set the initial directory for the Adobe AIR FileSystemTree control by setting the directory property to a File object, which in this case is the user documents direcotry.<br />]]><![CDATA[<div class="divcode"><pre lang="actionscript">&lt;mx:FileSystemTree id=&quot;tree&quot;<br />                   directory=&quot;{File.documentsDirectory}&quot;<br />                   width=&quot;100%&quot; height=&quot;100%&quot; /&gt;</pre></div><br /><br />]]></description>
      <author>Giorgio Natili</author>
      <pubDate>Wed, 30 Sep 2009 05:18:01 +0200</pubDate>
      <category>Air</category>
      <guid>http://snippet.gnstudio.com/viewtopic/21</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>
