<?xml version="1.0" encoding="utf-8"?>
			
			<rss version="2.0">
			<channel>
			<title>Lynch Consulting Blog - AIR</title>
			<link>http://www.lynchconsulting.com.au/blog/index.cfm</link>
			<description>A blog about ColdFusion, PHP, Flash, Flex, Web Standards and a mish mash of other technologies</description>
			<language>en-us</language>
			<pubDate>Tue, 07 Sep 2010 12:54:01 --1000</pubDate>
			<lastBuildDate>Tue, 17 Aug 2010 09:16:00 --1000</lastBuildDate>
			<generator>BlogCFC</generator>
			<docs>http://blogs.law.harvard.edu/tech/rss</docs>
			<managingEditor>mark@lynchconsulting.com.au</managingEditor>
			<webMaster>mark@lynchconsulting.com.au</webMaster>
			
			
			
			
			
			<item>
				<title>Signing Northcode Applications with MS Authenticode</title>
				<link>http://www.lynchconsulting.com.au/blog/index.cfm/2010/8/17/Signing-Northcode-Applications-with-MS-Authenticode</link>
				<description>
				
				Here&apos;s a quick howto for signing applications on windows which means that it won&apos;t show up as Author unknown.

Download the &lt;a href=&quot;http://www.microsoft.com/downloads/details.aspx?FamilyID=c17ba869-9671-4330-a63e-1fd44e0e2505&amp;displaylang=en&quot;&gt;Windows SDK&lt;/a&gt;.

Install it - I didn&apos;t install any of the code samples or help as I didn&apos;t want to wast 3.5G of space just for some code signing. Obviously it does a lot more than I was using it for :-).

If you have a code signing cert you need to install it into windows by double clicking on it and following the prompts.

Then simply run the following command:
&lt;code&gt;
&quot;c:\Program Files\Microsoft SDKs\Windows\v7.0\Bin\signtool.exe&quot; sign /a filenametosign.exe
Done Adding Additional Store
Successfully signed: filenametosign.exe
&lt;/code&gt;

Then when people run your application is will say the Author name instead of &quot;Unknown&quot;

Mark

See also: &lt;a href=&quot;http://www.northcode.com/blog.php/2010/01/08/How-do-I-get-rid-of-the-Unknown-Publisher-security-warning&quot;&gt;Northcode: How do I get rid of the &quot;Unknown Publisher&quot; security warning?&lt;/a&gt;
				
				</description>
				
				<category>AIR</category>
				
				<category>Actionscript</category>
				
				<pubDate>Tue, 17 Aug 2010 09:16:00 --1000</pubDate>
				<guid>http://www.lynchconsulting.com.au/blog/index.cfm/2010/8/17/Signing-Northcode-Applications-with-MS-Authenticode</guid>
				
			</item>
			
		 	
			
			
			<item>
				<title>Flex 3 to Flex 4 Migration Howto</title>
				<link>http://www.lynchconsulting.com.au/blog/index.cfm/2010/3/22/Flex-3-to-Flex-4-Migration-Howto</link>
				<description>
				
				I recently completed migrating an application from Flex3 to Flex4, and for my own reference, here&apos;s how I did it.

Note - this was done with flexsdk-4.0.0.13875, which was the most recent stable build at the time.

&lt;h2&gt;Phase 1:  Get Flex3 code compiling with Flex4&lt;/h2&gt;

&lt;h3&gt;Fix up stylesheets:&lt;/h3&gt;

If you have a current Flex3 project and you are migrating to Flex4 you need to add the following lines at the top of your stylesheet.
&lt;code&gt;
@namespace &quot;library://ns.adobe.com/flex/mx&quot;;
@namespace s &quot;library://ns.adobe.com/flex/spark&quot;;
&lt;/code&gt;

This makes the default non-namespaced items in your stylesheet refer to the MX components. eg:
&lt;code&gt;
Button{fontSize:18;}
&lt;/code&gt;
And to style up spark buttons you simply use:
&lt;code&gt;
s|Button{fontSize:18;}
&lt;/code&gt;

&lt;h3&gt;To statically link or not?&lt;/h3&gt;

Flex 4 defaults to dynamically linking runtime shared libraries.  This produces smaller files, but if you are making desktop type applications or developing code while not connected to the internet you&apos;ll probably want to statically link the files.  Add this to your compiler option:
&lt;code&gt;
-static-link-runtime-shared-libraries=true
&lt;/code&gt;


You now should have a happily compiling app, however, to use all the new goodness of flex 4 there are still some more steps to be done.

&lt;h2&gt;Phase 2: Using all of flex 4&lt;/h2&gt;

&lt;h3&gt;Update namespace to 2009&lt;/h3&gt;

To update the namespace references for flex 4 I did the following search and replace:
&lt;code&gt;
Replace:
xmlns:mx=&quot;http://www.adobe.com/2006/mxml&quot;
With:
xmlns:fx=&quot;http://ns.adobe.com/mxml/2009&quot; xmlns:mx=&quot;library://ns.adobe.com/flex/mx&quot; xmlns:s=&quot;library://ns.adobe.com/flex/spark&quot;
&lt;/code&gt;

&lt;h3&gt;Replace mx with fx namespace&lt;/h3&gt;

&lt;code&gt;
&lt;mx:Script&gt;  and &lt;/mx:Script&gt;
becomes:
&lt;fx:Script&gt;  and &lt;/fx:Script&gt;
&lt;/code&gt;

Similarly for other tags like this:
&lt;code&gt;
&lt;mx:Binding&gt;  to &lt;fx:Binding&gt;
&lt;mx:Metadata&gt;  to &lt;fx:Metadata&gt;
&lt;/code&gt;

&lt;h3&gt;Add Declarations for non visual components&lt;/h3&gt;

Wrap &lt;fx:Declarations&gt; tag around non visual compoents.  The compiler will complain about all these errors so just follow through and wrap them in 
&lt;code&gt;
&lt;fx:Declarations&gt;&lt;/fx:Declarations&gt; 
&lt;/code&gt;
tags until all the errors go away.


&lt;h3&gt;Migrate States&lt;/h3&gt;
Finally, at least for the project I migrated, I needed to convert all the state tags to the new format of inline attributes.

This shows up as the following error:
&lt;code&gt;
Error: State overrides may no longer be explicitly declared. The legacy states syntax has been deprecated.
&lt;/code&gt;

So if you had something like this before:
&lt;code&gt;
&lt;mx:State name=&quot;loading&quot;&gt; 
 &lt;mx:AddChild relativeTo=&quot;{myBox}&quot;&gt; 
  &lt;mx:Text textAlign=&quot;center&quot; text=&quot;Loading...&quot; selectable=&quot;false&quot; /&gt; 
 &lt;/mx:AddChild&gt;           
... snip ...
&lt;mx:VBox id=&quot;myBox&quot;&gt;	
&lt;/mx:VBox&gt;
&lt;/code&gt;

It would now look something like this:

&lt;code&gt;
&lt;mx:State name=&quot;loading&quot;&gt; 
... snip ...
&lt;mx:VBox id=&quot;myBox&quot;&gt;	
 &lt;mx:Text textAlign=&quot;center&quot; text=&quot;Loading...&quot; selectable=&quot;false&quot; 
	visible=&quot;false&quot; includeInLayout=&quot;false&quot;
	visible.loading=&quot;true&quot; includeInLayout.loading=&quot;true&quot;
 /&gt; 
&lt;/mx:VBox&gt;
&lt;/code&gt;


&lt;h3&gt;Migrate StyleManager References&lt;/h3&gt;

Stylemanager is not called as a global class any more and you need to use fully qualified references so:
&lt;code&gt;
thisImage.source = StyleManager.getStyleDeclaration(&quot;Image&quot;).getStyle(&quot;brokenImageSkin&quot;);
&lt;/code&gt;
becomes:
&lt;code&gt;
thisImage.source = styleManager.getStyleDeclaration(&quot;mx.controls.Image&quot;).getStyle(&quot;brokenImageSkin&quot;);
&lt;/code&gt;


When these have all been converted, your application should compile.

Then you can start leveraging the new functionality of flex4 and begin  migrating your components to spark if necessary.
				
				</description>
				
				<category>Open Source</category>
				
				<category>HOWTO</category>
				
				<category>Flex</category>
				
				<category>AIR</category>
				
				<category>Actionscript</category>
				
				<pubDate>Mon, 22 Mar 2010 09:50:00 --1000</pubDate>
				<guid>http://www.lynchconsulting.com.au/blog/index.cfm/2010/3/22/Flex-3-to-Flex-4-Migration-Howto</guid>
				
			</item>
			
		 	
			
			
			<item>
				<title>Migrating CSS from Flex 3 to Flex 4</title>
				<link>http://www.lynchconsulting.com.au/blog/index.cfm/2010/3/9/Migrating-CSS-from-Flex-3-to-Flex-4</link>
				<description>
				
				Having searched around for how to make CSS work when migrating to Flex 4 from Flex 3 and finding lots of incorrect namespace declarations I thought I&apos;d blog this as a reminder to myself:

If you have a current Flex3 project and you are migrating to Flex4 you need to add the following lines at the top of your stylesheet.
&lt;code&gt;
@namespace &quot;library://ns.adobe.com/flex/mx&quot;;
@namespace s &quot;library://ns.adobe.com/flex/spark&quot;;
&lt;/code&gt;

This makes the default non-namespaced items in your stylesheet refer to the MX components.  eg:
&lt;code&gt;
Button{fontSize:18;}
&lt;/code&gt;
And to style up spark buttons you simply use:
&lt;code&gt;
s|Button{fontSize:18;}
&lt;/code&gt;

Note there were lots of ones that I found that were wrong.  
&lt;h3&gt;Do NOT use:&lt;/h3&gt;
&lt;code&gt;
@namespace &quot;library://ns.adobe.com/flex/halo&quot;;
OR 
@namespace &quot;http://ns.adobe.com/mxml/2009&quot;;
&lt;/code&gt;

This info was sourced from the &lt;a href=&quot;http://opensource.adobe.com/wiki/display/flexsdk/CSS+Namespaces+Support&quot;&gt;Flex SDK Wiki&lt;/a&gt;.
				
				</description>
				
				<category>AIR</category>
				
				<category>Flex</category>
				
				<pubDate>Tue, 09 Mar 2010 10:34:00 --1000</pubDate>
				<guid>http://www.lynchconsulting.com.au/blog/index.cfm/2010/3/9/Migrating-CSS-from-Flex-3-to-Flex-4</guid>
				
			</item>
			
		 	
			
			
			<item>
				<title>Flex 4 RSL&apos;s and how to not use them</title>
				<link>http://www.lynchconsulting.com.au/blog/index.cfm/2010/3/8/Flex-4-RSLs-and-how-to-not-use-them</link>
				<description>
				
				Flex 4 allows and defaults to using Runtime Shared Libraries (RSL&apos;s).

These have advantages of making flash movies using them work very well, but they can also require more http requests the first time they are used, and are not good for application development with Northcode.

To turn them off you need to add the following compiler flag:
&lt;code&gt;
 -static-link-runtime-shared-libraries=true
&lt;/code&gt;

Thanks to &lt;a href=&quot;http://butterfliesandbugs.wordpress.com/2009/07/14/rsls-on-my-default-in-flex-4/&quot;&gt;Flex Butterflies and bugs for the info&lt;/a&gt;.
				
				</description>
				
				<category>AIR</category>
				
				<category>Flex</category>
				
				<pubDate>Mon, 08 Mar 2010 21:55:00 --1000</pubDate>
				<guid>http://www.lynchconsulting.com.au/blog/index.cfm/2010/3/8/Flex-4-RSLs-and-how-to-not-use-them</guid>
				
			</item>
			
		 	
			
			
			<item>
				<title>ExtendoText project on google code</title>
				<link>http://www.lynchconsulting.com.au/blog/index.cfm/2009/4/8/ExtendoText-project-on-google-code</link>
				<description>
				
				We&apos;ve been busy squirrelling away on many projects and they are beginning to come to light:

One which is coming to light very early is a new text framework for actionscript which leverages flash 10 text engine.

It&apos;s very early alpha but is a good proof of concept and already solves some problems for us - namely the ability to simply create rich text area&apos;s that have superscript and subscript text.

It uses XML and CSS and completely seperates the formatting from the content.

&lt;img src=&quot;http://www.lynchconsulting.com.au/blog/enclosures/extendotext-0.1.png&quot; alt=&quot;Screenshot of extendotext 0.1&quot; align=&quot;right&quot; /&gt;

It can now:
&lt;ul&gt;
&lt;li&gt;Render a simple XML document&lt;/li&gt;
&lt;li&gt;Apply styles including color, font and opacity&lt;/li&gt;
&lt;li&gt;Plug in custom code for rendering images, video or any other XML tag you want to create.&lt;/li&gt;
&lt;/ul&gt;


The screenshot highlights a number of these features:
&lt;ul&gt;
&lt;li&gt;Bold, italic, super and subscript text&lt;/li&gt;
&lt;li&gt;Text wrapping around custom display classes (Red and Green boxes)&lt;/li&gt;
&lt;li&gt;Opacity applied to display objects (green box)&lt;/li&gt;
&lt;/ul&gt;

There is still a lot more to be done - including editing of text which is the next hard piece to knock over.

You can get it from &lt;a href=&quot;http://code.google.com/p/extendotext/&quot;&gt;the google code site&lt;/a&gt;

Keen to hear any feedback.

Cheers,
Mark
				
				</description>
				
				<category>Open Source</category>
				
				<category>Flex</category>
				
				<category>AIR</category>
				
				<category>Actionscript</category>
				
				<pubDate>Wed, 08 Apr 2009 09:09:00 --1000</pubDate>
				<guid>http://www.lynchconsulting.com.au/blog/index.cfm/2009/4/8/ExtendoText-project-on-google-code</guid>
				
			</item>
			
		 	
			
			
			<item>
				<title>More of AIR Gzip compression</title>
				<link>http://www.lynchconsulting.com.au/blog/index.cfm/2009/3/19/More-of-AIR-Gzip-compression</link>
				<description>
				
				Further to &lt;a href=&quot;http://www.lynchconsulting.com.au/blog/index.cfm/2009/3/6/GZIP-encoding-in-Adobe-AIRFlex-HOWTO&quot;&gt;Marko&apos;s blog entry on implementing Gzip compression&lt;/a&gt; in AIR applications - turns out we were impressively hoodwinked.

By adding the &apos;Accept-Encoding&apos;:&apos;gzip&apos; header we were telling our apache server to serve up the compressed version of the content and we could see the content was compressed coming through Charles Proxy, and our application was working perfectly.

However, I started working on the exact same code the next day and straight away got an error - the application was erroring because it was getting binary data where it expected the decompressed XML data.

I turned Charles back on to see what was going on and it started working again.  With my best sherlock holmes head on I rapidly deduced that Charles as well as proxying the request was also decompressing it helpfully for me.

Luckily I&apos;d already come across the solution to the problem courtesy of &lt;a href=&quot;http://anirudhs.chaosnet.org/blog/2008.06.20.html&quot;&gt;Anirudh Sasikumar (GzipHTTPService)&lt;/a&gt; and &lt;a href=&quot;http://probertson.com/projects/gzipencoder/&quot;&gt;Paul Robertson (Gzip Encoder)&lt;/a&gt;.

I made some minor modifications to Anirudh&apos;s Gzip HTTP Service to do two things.
&lt;ul&gt;
&lt;li&gt;Always send the header &apos;Accept-Encoding&apos;:&apos;gzip&apos; if running a Desktop (Aka AIR) app.&lt;/li&gt;
&lt;li&gt;Handle the case where the Gzip response that comes back is not gzip compressed.  I.e. Charles already decrypted it or the server doesn&apos;t support gzip compression.&lt;/li&gt;
&lt;li&gt;Change it to use version 0.2.0 of the gzip encoder&lt;/li&gt;
&lt;/ul&gt;

With these changes it is a drop in replacement for the &amp;lt;mx:HTTPService/&amp;gt; tag.

The changes are as follows:

&lt;code&gt;
...snip....
        public function GzipHTTPService(rootURL:String=null, destination:String=null)
        {
            super(rootURL, destination);
   			//If using AIR then set accept GZIP
			if(Capabilities.playerType == &quot;Desktop&quot;)
			{
				this.headers = {&apos;Accept-Encoding&apos;:&apos;gzip&apos;};
			}
        }

...snip....      
            else if ( body is ByteArray )
            {
                var barr:ByteArray = body as ByteArray;
                
                try{
                	var encoder:GZIPBytesEncoder = new GZIPBytesEncoder();
                	/* decode the gzip encoded result */
                	message.body = encoder.uncompressToByteArray(barr).toString();
                }catch(error:IllegalOperationError){
                	//Not gzip compressed - assume utf8
                	barr.position = 0;//reset to start of bytearray
                	message.body = barr.readUTFBytes(barr.length);
                }
                /* pass it on to HTTPService */
                return super.processResult(message, token);				
            }

...snip...
&lt;/code&gt;


For convenience you can &lt;a href=&quot;http://www.lynchconsulting.com.au/blog/enclosures/GzipHTTPService_ml.zip&quot;&gt;download the modified files from here&lt;/a&gt;.

Hope it helps.

Cheers,
Mark
				
				</description>
				
				<category>Actionscript</category>
				
				<category>AIR</category>
				
				<category>Flex</category>
				
				<pubDate>Thu, 19 Mar 2009 21:37:00 --1000</pubDate>
				<guid>http://www.lynchconsulting.com.au/blog/index.cfm/2009/3/19/More-of-AIR-Gzip-compression</guid>
				
			</item>
			
		 	
			
			
			<item>
				<title>GZIP encoding in Adobe AIR/Flex - HOWTO</title>
				<link>http://www.lynchconsulting.com.au/blog/index.cfm/2009/3/6/GZIP-encoding-in-Adobe-AIRFlex-HOWTO</link>
				<description>
				
				If you use HTTPService component in Flex or AIR to retrieve data from a server, you might want to consider gzipping the response.  This can significantly reduce the packet size you get from the server, which results in a much better application performance.

This means that response packet is compressed by Apache web server and your client will need to decompress it.  Fortunately, both Flex and AIR 1.5.1 natively support GZIP compression.  However there are a couple of things you need to watch out for.

Firstly, you need to enable &lt;a href=&quot;http://httpd.apache.org/docs/2.0/mod/mod_deflate.html&quot;&gt;Apache Module mod_deflate&lt;/a&gt; in your virtual host.

In your AIR application, you need to tell HTTPService component to accept gzip encoding and AIR will take care of the rest:
&lt;code&gt;
&lt;mx:HTTPService id=&quot;service&quot; resultFormat=&quot;e4x&quot; /&gt;
this.service.headers = {&apos;Accept-Encoding&apos;:&apos;gzip&apos;};
&lt;/code&gt;

If you are in a Flex project, specifying gzip encoding will throw the following error:
&lt;code&gt;
ArgumentError: Error #2096: The HTTP request header Accept-Encoding cannot be set via ActionScript.
&lt;/code&gt;

This is because Flex apps run in a browser and the browser is responsible for determining encoding type and decompression (if required).  Therefore, you cannot specify encoding type in Flex apps.

Our problem is that we use one core library for AIR and Flex applications.  So the issue above can be avoided by conditionally specifying encoding type depending on the framework used.  This can be done in 2 lines of code:
&lt;code&gt;
if(Capabilities.playerType == &quot;Desktop&quot;)
   this.service.headers = {&apos;Accept-Encoding&apos;:&apos;gzip&apos;};
&lt;/code&gt;

&lt;p&gt;&lt;strong&gt;Note: this is not the complete solution - &lt;a href=&quot;http://www.lynchconsulting.com.au/blog/index.cfm/2009/3/19/More-of-AIR-Gzip-compression&quot;&gt;check out this entry for the rest of it&lt;/a&gt; :-)&lt;/strong&gt;&lt;/p&gt;

Cheers
Marko
				
				</description>
				
				<category>HOWTO</category>
				
				<category>Flex</category>
				
				<category>AIR</category>
				
				<category>Actionscript</category>
				
				<pubDate>Fri, 06 Mar 2009 12:27:00 --1000</pubDate>
				<guid>http://www.lynchconsulting.com.au/blog/index.cfm/2009/3/6/GZIP-encoding-in-Adobe-AIRFlex-HOWTO</guid>
				
			</item>
			
		 	
			
			
			<item>
				<title>AS3 BulkLoader example</title>
				<link>http://www.lynchconsulting.com.au/blog/index.cfm/2009/2/20/AS3-BulkLoader-example</link>
				<description>
				
				I&apos;ve been using &lt;a href=&quot;http://code.google.com/p/bulk-loader/&quot;&gt;AS3 BulkLoader&lt;/a&gt; for a while, which is great for loading multiple assets such as images and swfs into your application.  Typical usage would look something like this:

instantiate BulkLoader object:
&lt;code&gt;
private var assetLoader:BulkLoader = new BulkLoader(&quot;instanceName&quot;);
&lt;/code&gt;

add assets into the queue:
&lt;code&gt;
this.assetLoader.add(&quot;assets/myImage.jpg&quot;, {id:&quot;key1&quot;});
this.assetLoader.add(&quot;assets/myMovie.swf&quot;, {id:&quot;key2&quot;});
&lt;/code&gt;
where id is the key, which is used to identify which asset to retrieve from the queue once it&apos;s been loaded.

To start loading assets you simply call the start() method:
&lt;code&gt;
this.assetLoader.start();
&lt;/code&gt;

To get asset content, you would normally call getContent() method, which would return Bitmap for images or AVM1Movie for swf files.  You could also call methods like getBitmap() and getAVM1Movie() to target specific file types.

The problem I encountered was that assets I was loading were encrypted.  Therefore, I needed to read them in as ByteArray type and then decrypt them.  Fortunately the latest version of BulkLoader has getBinary() method, but there is a trick to it.  You need to tell BulkLoader to load assets in binary format when adding items into the queue:
&lt;code&gt;
this.assetLoader.add(&quot;assets/myImage.jpg&quot;, {id:&quot;key1&quot;, type:BulkLoader.TYPE_BINARY});
this.assetLoader.add(&quot;assets/myMovie.swf&quot;, {id:&quot;key2&quot;, type:BulkLoader.TYPE_BINARY});
&lt;/code&gt;
And after all assets have been loaded, you get binary content:
&lt;code&gt;
var assetBinary1:ByteArray = this.assetLoader.getBinary(&quot;key1&quot;);
var assetBinary2:ByteArray = this.assetLoader.getBinary(&quot;key2&quot;);
&lt;/code&gt;
Without specifying the type, BulkLoader will try to load data in text format which will result in the following error:
&lt;code&gt;
[BulkLoader] Failed to get content with url: &apos;file:///myFile.jpg&apos;as type: [class ByteArray]
&lt;/code&gt;

Setting the type to binary did the trick for me, so I thought I&apos;d share it in case someone else falls into the same trap.

Oh, and I should thank Mark Lynch for helping me figure this out :-)

Marko
				
				</description>
				
				<category>Flex</category>
				
				<category>AIR</category>
				
				<category>Actionscript</category>
				
				<pubDate>Fri, 20 Feb 2009 11:34:00 --1000</pubDate>
				<guid>http://www.lynchconsulting.com.au/blog/index.cfm/2009/2/20/AS3-BulkLoader-example</guid>
				
			</item>
			
		 	
			
			
			<item>
				<title>Can&apos;t Launch Air Apps after upgrading Flex Builder to 3.0.2</title>
				<link>http://www.lynchconsulting.com.au/blog/index.cfm/2009/1/14/Cant-Launch-Air-Apps-after-upgrading-Flex-Builder-to-302</link>
				<description>
				
				I recently upgraded flex builder to 3.0.2 to play with the new Flash 10 goodness and came across this little problem. 

Whenever I clicked run it would just sit there for ages and never launch the app.  If I clicked debug I got the following error:

&lt;code&gt;
Process terminated without establishing connection to debugger.

Command:

&quot;C:\Program Files\Adobe\Flex Builder 3\sdks\3.2.0\bin\adl.exe&quot; &quot;C:\Documents and Settings\markl\My Documents\Flex Builder 3\SampleApp\bin-debug\SampleApp-app.xml&quot; &quot;C:\Documents and Settings\markl\My Documents\Flex Builder 3\DexterAir\bin-debug&quot; 

Output from command:

error while loading initial content
&lt;/code&gt;

Turns out the solution is easy when you know how, thanks to &lt;a href=&quot;http://www.bobsgear.com/display/ts/Can%27t+Launch+Air+Apps+After+Upgrading+from+Flex+Builder+3.01+to+Flex+Builder+3.02?replyToComment=24903696&quot;&gt;this post&lt;/a&gt;.

The solution is a simple as changing the namespace in the app.xml file from:

&lt;code&gt;
&lt;application xmlns=&quot;http://ns.adobe.com/air/application/1.0&quot;&gt;
&lt;/code&gt;
to
&lt;code&gt;
&lt;application xmlns=&quot;http://ns.adobe.com/air/application/1.5&quot;&gt;
&lt;/code&gt;

Which is fine if you want to upgrade you app to 1.5 - not sure if there is still a way to compile apps for AIR 1.0 though.

Cheers,
Mark Lynch
				
				</description>
				
				<category>Actionscript</category>
				
				<category>AIR</category>
				
				<category>Flex</category>
				
				<pubDate>Wed, 14 Jan 2009 07:33:00 --1000</pubDate>
				<guid>http://www.lynchconsulting.com.au/blog/index.cfm/2009/1/14/Cant-Launch-Air-Apps-after-upgrading-Flex-Builder-to-302</guid>
				
			</item>
			
		 	
			
			
			<item>
				<title>Flash Text Layout Framework - Getting Started</title>
				<link>http://www.lynchconsulting.com.au/blog/index.cfm/2008/12/16/Flash-Text-Layout-Framework--Getting-Started</link>
				<description>
				
				&lt;div style=&quot;float: right;&quot;&gt;
&lt;a href=&quot;http://www.lynchconsulting.com.au/blog/enclosures/textlayoutdemo.swf&quot;&gt;&lt;img src=&quot;http://www.lynchconsulting.com.au/blog/enclosures/textlayoutdemo.png&quot; alt=&quot;View Demo&quot;&gt;&lt;/a&gt;&lt;br&gt;
&lt;a href=&quot;http://www.lynchconsulting.com.au/blog/enclosures/textlayoutdemo.mxml&quot;&gt;Download Code&lt;/a&gt;
&lt;/div&gt;

I finally got some time to play with Flash 10 and the new text functionality including the &lt;a href=&quot;http://labs.adobe.com/technologies/textlayout/&quot;&gt;Text Layout Framework Beta&lt;/a&gt;

It gives very powerful control of the text layout but with this power come a few gotcha&apos;s which can trip you up.

The basic process for using the TextFlow for advanced text rendering is as follows:
&lt;ul&gt;
&lt;li&gt;Create a sprite container to hold the text&lt;/li&gt;
&lt;li&gt;Import the text into a TextFlow object&lt;/li&gt;
&lt;li&gt;Attach the container to the textflow object&lt;/li&gt;
&lt;li&gt;Call updateAllContainers() on the textflow object&lt;/li&gt;
&lt;li&gt;We also need to add event handlers for resize and graphics loading if we are using these features.&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;Create a sprite&lt;/h3&gt;

&lt;code&gt;
_container = new Sprite();
this.textArea.rawChildren.addChild(_container);
this.textArea.addEventListener(ResizeEvent.RESIZE,resizeEvent);
&lt;/code&gt;
Create a new sprite which get&apos;s attached to the canvas we&apos;ve already created.
&lt;code&gt;
&lt;mx:Canvas id=&quot;textArea&quot; top=&quot;10&quot; left=&quot;10&quot; right=&quot;10&quot; bottom=&quot;10&quot;/&gt;
&lt;/code&gt;

&lt;h3&gt;Import the text into a TextFlow object&lt;/h3&gt;

&lt;code&gt;
XML.ignoreWhitespace = false;			

var markup:XML  = &lt;TextFlow fontSize=&quot;30&quot; fontFamily=&quot;Arial&quot; whiteSpaceCollapse=&quot;preserve&quot;&gt;
	&lt;p fontSize=&quot;50&quot; textAlign=&quot;center&quot;&gt;Text Layout Framework Demo&lt;/p&gt;
	&lt;p&gt;Text is now easy to control in Flash&lt;/p&gt;
	&lt;p&gt;&lt;span&gt;It can be formatted easily to do&lt;/span&gt;&lt;span fontWeight=&quot;bold&quot; whiteSpaceCollapse=&quot;preserve&quot;&gt; Bold&lt;/span&gt;&lt;span&gt;, &lt;/span&gt;&lt;span fontStyle=&quot;italic&quot;&gt;Italic&lt;/span&gt;&lt;span&gt;, &lt;/span&gt;&lt;span textDecoration=&quot;underline&quot;&gt;Underline&lt;/span&gt;&lt;span&gt; and &lt;/span&gt;&lt;span lineThrough=&quot;true&quot;&gt; Strikethrough&lt;/span&gt;&lt;/p&gt;
	&lt;p&gt;It can also finally do &lt;span fontSize=&quot;20&quot;  alignmentBaseline=&quot;ideographicTop&quot;&gt;Superscript&lt;/span&gt; and &lt;span fontSize=&quot;20&quot;  alignmentBaseline=&quot;ideographicBottom&quot;&gt;Subscript&lt;/span&gt;&lt;/p&gt;
	&lt;p&gt;&lt;a href=&apos;http://www.learnosity.com/techblog/&apos;&gt;Links&lt;/a&gt; and inline images  &lt;img align=&quot;right&quot; source=&quot;http://www.adobe.com/shockwave/download/images/flashplayer_100x100.jpg&quot; /&gt; are also available&lt;/p&gt;
&lt;/TextFlow&gt;;

_textFlow = TextFilter.importToFlow(markup,TextFilter.TEXT_LAYOUT_FORMAT);
&lt;/code&gt;

This loads the XML and stores it in the _textFlow object.  

&lt;strong&gt;Note:&lt;/strong&gt; the XML.ignoreWhitespace is important otherwise it all the whitespace between tags will get stripped out and any formatted text will lose it&apos;s spacing.			
				
&lt;h3&gt;Attach the container to the textflow object&lt;/h3&gt;

&lt;code&gt;
_textFlow.flowComposer.addController(new DisplayObjectContainerController(_container,textArea.width,textArea.height));
&lt;/code&gt;

&lt;h3&gt;Call updateAllContainers() on the textflow object&lt;/h3&gt;
&lt;code&gt;
_textFlow.flowComposer.updateAllContainers();
&lt;/code&gt;

That&apos;s it.

For bonus points you can add the event handlers to handle graphics loading and resize etc.

&lt;code&gt;
this.textArea.addEventListener(ResizeEvent.RESIZE,resizeEvent);
_textFlow.addEventListener(StatusChangeEvent.INLINE_GRAPHIC_STATUS_CHANGED,graphicStatusChangeEvent);	
&lt;/code&gt;
And the functions they call look like this:
&lt;code&gt;
		public function graphicStatusChangeEvent(evt:Event):void
		{
			// the graphic has loaded (or failed to load) update the display
			_textFlow.flowComposer.updateAllContainers();
		}	
		public function resizeEvent(evt:Event):void
		{
			//Resize event - recreate the flowcompser with the correct width and height
			_textFlow.flowComposer.removeAllControllers();	
			_textFlow.flowComposer.addController(new DisplayObjectContainerController(_container,textArea.width,textArea.height));
			_textFlow.flowComposer.updateAllContainers();
		}		
&lt;/code&gt;


&lt;h3&gt;Make it selectable&lt;/h3&gt;
To make the text selectable we just need to add an interaction manager.  As easy as this:
&lt;code&gt;
//To make selectable
_textFlow.interactionManager = new SelectionManager();
&lt;/code&gt;


I&apos;m looking forward to implementing the rest of this in our projects that use flash text.  It&apos;s so much simpler and cleaner.

Cheers,
Mark
				
				</description>
				
				<category>Flex</category>
				
				<category>AIR</category>
				
				<category>Actionscript</category>
				
				<pubDate>Tue, 16 Dec 2008 17:16:00 --1000</pubDate>
				<guid>http://www.lynchconsulting.com.au/blog/index.cfm/2008/12/16/Flash-Text-Layout-Framework--Getting-Started</guid>
				
			</item>
			
		 	
			
			
			<item>
				<title>Extracting from sound from Flash (aka NellyMoser)</title>
				<link>http://www.lynchconsulting.com.au/blog/index.cfm/2008/7/23/Extracting-from-sound-from-Flash-aka-NellyMoser-codec-sucks</link>
				<description>
				
				A current project that we are working on requires us to be able to record sound via a flash plugin.  Initially I thought it would be nice and easy as I&apos;ve seen demos of both video and audio broadcasting - however, the one big problem is that the current flash client only allows you to record video to a netstream, you can&apos;t get any access to it in the flash player.

So you need something like &lt;a href=&quot;http://www.adobe.com/products/flashmediaserver/&quot;&gt;Flash Media Server&lt;/a&gt; or &lt;a href=&quot;http://osflash.org/red5&quot;&gt;Red5&lt;/a&gt; to record it. 

However, once you record it to the server it is an flv and the audio codec is stored as a NellyMoser encoded audio portion.  This codec is not supported by many applications and after a quick google found the nelly2pcm project on google code.

This will convert a flv sound file to a raw pcm file - which you can then do useful stuff with.  So here&apos;s how to do it on a Ubuntu machine.

&lt;ul&gt;
&lt;li&gt;Ensure you have build tools: (apt-get install build-essential)&lt;/li&gt;
&lt;li&gt;Download &lt;a href=&quot;http://code.google.com/p/nelly2pcm/downloads/list&quot;&gt;nelly2pcm from google code&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;Extract and Compile it, &lt;/li&gt;
&lt;/ul&gt;
&lt;code&gt;
$ tar -xjvf nelly2pcm.tar.bz2
$ cd nelly2pcm
$ make
cc -Wall   -c -o nelly2pcm.o nelly2pcm.c
cc -Wall   -c -o nelly.o nelly.c
cc -Wall   -c -o nelly_tables.o nelly_tables.c
cc -Wall nelly2pcm.o nelly.o nelly_tables.o -lm -o nelly2pcm
&lt;/code&gt;
You should now have a nelly2pcm executable file in this directory.

You can run it as follows:
&lt;code&gt;
$ ./nelly2pcm test.flv &gt; test.raw
mono Nellymoser stream with 16-bit samples at 44kHz
&lt;/code&gt;


This will create a raw sound file with no headers and output the line above which you&apos;ll need for the next part.

To play this file back you can use sox (apt-get install sox)

&lt;code&gt;
$ play -r 44100 -c 1 -2 -s test.raw 
&lt;/code&gt;

If you&apos;ve got all the options correct then this will play the file back.  Once you got it correct you can then use sox to create a wav file which is essentially the same except that it has a header which contains all the settings (eg bitrate etc)

&lt;code&gt;
$ sox -r 44100 -c 1 -2 -s test.raw test.wav
&lt;/code&gt;

From a wav you can convert to whatever you like.  I&apos;m looking forward to the Flash Player 10 release as this messing will no longer be necessary as it will support encoding with the &lt;a href=&quot;http://www.speex.org/&quot;&gt;free Speex codec&lt;/a&gt;.

Cheers,
Mark


&lt;h3&gt;Update:&lt;/h3&gt;
In the 12 hours since I wrote this post it appears that a &lt;a href=&quot;http://code.google.com/hosting/takenDown?project=nelly2pcm&amp;notice=7281&quot;&gt;DMCA takedown notice has been served on the nelly2pcm&lt;/a&gt; site and google have taken it down.  I&apos;ve no idea if it&apos;s related to this post or not and &lt;a href=&quot;http://www.chillingeffects.org/notice.cgi?sID=7281&quot;&gt;no details are available yet on the chillingeffects site&lt;/a&gt; but hopefully it will be updated shortly.  As I mentioned earlier, I can&apos;t wait for flash 10 with the speex codec so we don&apos;t have to use Nellymoser, well done Adobe for including it.
				
				</description>
				
				<category>Ubuntu</category>
				
				<category>Open Source</category>
				
				<category>Linux</category>
				
				<category>AIR</category>
				
				<category>Actionscript</category>
				
				<pubDate>Wed, 23 Jul 2008 23:58:00 --1000</pubDate>
				<guid>http://www.lynchconsulting.com.au/blog/index.cfm/2008/7/23/Extracting-from-sound-from-Flash-aka-NellyMoser-codec-sucks</guid>
				
			</item>
			
		 	
			
			
			<item>
				<title>&quot;Logical AND&quot; with flex binding in mxml</title>
				<link>http://www.lynchconsulting.com.au/blog/index.cfm/2008/6/13/Logical-AND-with-flex-binding-in-mxml</link>
				<description>
				
				While making a small change to a view in one of our flex app&apos;s I came across the following little problem.

Initially there was a single parameter binding which set the button enabled, eg:

&lt;code&gt;
  &lt;mx:Button enabled=&quot;{model.user.allowSomething}&quot; label=&quot;Do Something&quot;&gt;
&lt;/code&gt;

The business requirements changed and we need to have a global setting as well as a user setting, so now the setting had to be globally enabled and the user had to have access to it.

My 1st attempt was this:
&lt;code&gt;
  &lt;mx:Button enabled=&quot;{model.settings.allowSomething &amp;&amp; model.user.allowSomething}&quot; label=&quot;Do Something&quot;&gt;
&lt;/code&gt;

However, this gave the following error:
&lt;blockquote&gt;
The entity name must immediately follow the &apos;&amp;&apos; in the entity reference.
&lt;/blockquote&gt;

This you may recognise as an XML formatting error.  After a quick google I came across &lt;a href=&quot;http://bugs.adobe.com/jira/browse/SDK-12930&quot;&gt;a bug in the adobe bug tracker&lt;/a&gt; related to this (BTW I love that this is now open and searchable) which explained the workaround.  XML escape the characters - which feels ugly when writing code, but it does make sense. 

So the code now becomes:
&lt;code&gt;
  &lt;mx:Button enabled=&quot;{model.settings.allowSomething &amp;amp;&amp;amp; model.user.allowSomething}&quot; label=&quot;Do Something&quot;&gt;
&lt;/code&gt;

I also came across another way of &lt;a href=&quot;http://blog.flexmonkeypatches.com/2007/12/05/damn-ampersands-escaping-in-expressions-or-using-compoundternary-logic-expressions/&quot;&gt;handling it using the ternary operator&lt;/a&gt; which is very clever but I think it is even less readable than the escaped XML characters.

Cheers,
Mark
				
				</description>
				
				<category>Flex</category>
				
				<category>AIR</category>
				
				<category>Actionscript</category>
				
				<pubDate>Fri, 13 Jun 2008 22:42:00 --1000</pubDate>
				<guid>http://www.lynchconsulting.com.au/blog/index.cfm/2008/6/13/Logical-AND-with-flex-binding-in-mxml</guid>
				
			</item>
			
		 	
			
			
			<item>
				<title>Flex/AIR embedded fonts - Exception during Transcoding - Solved</title>
				<link>http://www.lynchconsulting.com.au/blog/index.cfm/2008/6/7/FlexAIR-embedded-fonts--Exception-during-Transcoding--Solved</link>
				<description>
				
				I&apos;ve come across this error a number of times:

&lt;code&gt;
exception during transcoding: Unexpected exception encountered while reading font file &apos;/C:/Documents and Settings/markl/My Documents/Flex Builder 3/DexterNorthCode/src/assets/DejaVuSans-Bold.ttf&apos;
&lt;/code&gt;

It can be very frustrating as there is not much information to be gleaned from the error messages and the whole font area is very murky and complicated.

There are a number for reasons that this error will occur
&lt;ul&gt;
&lt;li&gt;If you reference the wrong file&lt;/li&gt;
&lt;li&gt;If you specify the fontStyle or fontWeight wrong&lt;/li&gt;
&lt;li&gt;or most frustratingly if the font manager can&apos;t interpret the font correctly.&lt;/li&gt;
&lt;/ul&gt;

After grappling with this problem for I while and after much reading I realised that there are &lt;a href=&quot;http://livedocs.adobe.com/flex/3/html/help.html?content=fonts_06.html&quot;&gt;3 different &quot;font managers&quot;&lt;/a&gt; that transcode fonts in AS3.  These are:
&lt;ul&gt;
&lt;li&gt;flash.fonts.JREFontManager&lt;/li&gt;
&lt;li&gt;flash.fonts.AFEFontManager&lt;/li&gt;
&lt;li&gt;flash.fonts.BatikFontManager&lt;/li&gt;
&lt;/ul&gt;

The different font managers have different capabilities and should be automatically selected to choose the best one.  However, this is not always the case.

You can force the compiler to use a specific manager by appending the following to the compiler arguments.

Project-&gt;Properties-&gt;Flex Compiler-&gt;Additional compiler arguments:

&lt;code&gt;
-managers=flash.fonts.AFEFontManager
&lt;/code&gt;

This forces the use of the AFEFontManager which seems to have the best support for fonts and is the one being most actively developed.
				
				</description>
				
				<category>Actionscript</category>
				
				<category>AIR</category>
				
				<category>Flex</category>
				
				<pubDate>Sat, 07 Jun 2008 10:17:00 --1000</pubDate>
				<guid>http://www.lynchconsulting.com.au/blog/index.cfm/2008/6/7/FlexAIR-embedded-fonts--Exception-during-Transcoding--Solved</guid>
				
			</item>
			
		 	
			
			
			<item>
				<title>Rich formatting for PDF&apos;s directly from Actionscript</title>
				<link>http://www.lynchconsulting.com.au/blog/index.cfm/2008/5/10/Rich-formatting-for-PDFs-directly-from-Actionscript</link>
				<description>
				
				I&apos;ve &lt;a href=&quot;http://www.lynchconsulting.com.au/blog/index.cfm/2008/3/27/PDF-Generation-in-Actionscript--AlivePDF&quot;&gt;blogged previously about the AlivePDF libraries&lt;/a&gt; which allow you to create PDF&apos;s directly from Actionscript.

I&apos;ve been using them for a project and all was going well until we hit a limitation in the libraries.  We can do rich formatting and we can do automatic line wrapping and pagination, but we can&apos;t do the both together.  

&lt;a href=&quot;http://www.lynchconsulting.com.au/blog/enclosures/test.pdf&quot;&gt;&lt;img src=&quot;http://www.lynchconsulting.com.au/blog/enclosures/test.pdf.png&quot; align=&quot;right&quot; alt=&quot;Screenshot of generated pdf&quot;&gt;&lt;/a&gt;

This would have been an enormous problem if this was a piece of commercial software as we would be completely at the mercy of the creators.  However, as it is Open Source we have access to the code and we can extend it as we see fit.  

And that&apos;s exactly what we did.  I&apos;ve added a new version of the &lt;strong&gt;writeText()&lt;/strong&gt; method called very imaginatively &lt;strong&gt;writeText2()&lt;/strong&gt;.

It takes the same parameters but instead of taking a standard string it will render a string that has html markup.  I.e. you can put a &amp;lt;b&amp;gt; tag in and your text will be bold.  Eg:

&lt;code&gt;
// This will write the following text with appropriate styling and word wrapping
pdf.writeText2 ( 15, &apos;A long &lt;u&gt;piece&lt;/u&gt; of &lt;b&gt;text&lt;/b&gt; in &lt;center&gt;1111 center 1111 2222 center 2222 3333 center 3333 &lt;b&gt;BOLD TEXT&lt;/b&gt; 4444 center 4444&lt;/center&gt;standard format that should wrap by the time I finish this. AAAAAAAAAAAAAAAABBBBBBBBBBBBCCCCCCCCCCCCCCAAA &lt;i&gt;Italic text&lt;/i&gt;. &lt;b&gt;Some bold text&lt;/b&gt;.  And now for some &lt;b&gt;&lt;i&gt;Bold and Italic Text&lt;/i&gt;&lt;/b&gt;.  And back to normal.  Then a line break&lt;br/&gt; That\&apos;s All.&apos;	);
&lt;/code&gt;

For the curious you can &lt;a href=&quot;http://www.lynchconsulting.com.au/blog/enclosures/test.pdf&quot;&gt;download a sample document generated by it&lt;/a&gt;.


It currently supports the following tags:
&lt;ul&gt;
&lt;li&gt;&amp;lt;b&amp;gt; Make it bold&lt;/li&gt;
&lt;li&gt;&amp;lt;u&amp;gt; Underline it&lt;/li&gt;
&lt;li&gt;&amp;lt;i&amp;gt; Make it italic&lt;/li&gt;
&lt;li&gt;&amp;lt;center&amp;gt; Center it&lt;/li&gt;
&lt;li&gt;&amp;lt;br /&amp;gt; Add a line break&lt;/li&gt;
&lt;/ul&gt;

The code still needs a some cleanup and more testing but it seems to be reliable now.

The two files that were &lt;a href=&quot;http://www.lynchconsulting.com.au/blog/enclosures/alivePDF-writeText2-changed.zip&quot;&gt;changed are available for download&lt;/a&gt;. Or alternatively you can &lt;a href=&quot;http://www.lynchconsulting.com.au/blog/enclosures/alivePDF-writeText2.zip&quot;&gt;download the full version with changes included&lt;/a&gt;. Give it a try and let me know what you think.

Cheers,
Mark Lynch
				
				</description>
				
				<category>Actionscript</category>
				
				<category>AIR</category>
				
				<category>Flex</category>
				
				<category>Open Source</category>
				
				<pubDate>Sat, 10 May 2008 23:25:00 --1000</pubDate>
				<guid>http://www.lynchconsulting.com.au/blog/index.cfm/2008/5/10/Rich-formatting-for-PDFs-directly-from-Actionscript</guid>
				
			</item>
			
		 	
			
			
			<item>
				<title>Job Vacancy Sydney AU - Graduate or Junior OO Programmer</title>
				<link>http://www.lynchconsulting.com.au/blog/index.cfm/2008/5/9/Job-Vacancy-Sydney-AU--Graduate-or-Junior-OO-Programmer</link>
				<description>
				
				We&apos;re looking for a Computer Science Graduate or similar with strong Object Oriented programming skills and the ability to grasp cutting edge technologies quickly.

If you are looking to work with the latest technogies and are a motivated self starter with a positive &quot;can do&quot; attitude this is the job for you. The ability to take problems and deliver solutions is a must.

There will be significant on the job learning as we are always pushing the boundaries and using the latest and greatest technologies. We are currently working on projects using Actionscript/Flex, ColdFusion, PHP, and Javascript, and are leveraging technologies such as VOIP, SMS, Instant Messenger (Jabber XMPP) to deliver cutting edge solutions.

Suitable applicants will have a Bachelors Degree in Computer Science or Engineering, or similar tertiary qualification. Remuneration commensurate with experience.

&lt;h3&gt;Responsibilities would include:&lt;/h3&gt;
&lt;ul&gt;
&lt;li&gt;Developing new functionality for Asterisk and VOIP applications&lt;/li&gt;
&lt;li&gt;Creating Rich Internet Applications with Adobe Flex&lt;/li&gt;
&lt;li&gt;Creation of Desktop applications with Adobe AIR&lt;/li&gt;
&lt;li&gt;Design and development of new Web applications&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;Must haves:&lt;/h3&gt;
&lt;ul&gt;
&lt;li&gt;A robust foundation in Object Oriented programming&lt;/li&gt;
&lt;li&gt;Demonstrated experience in at least one OO language&lt;/li&gt;
&lt;li&gt;Motivation to learn and push the boundaries&lt;/li&gt;
&lt;li&gt;Understanding of XHTML and CSS&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;Preferable:&lt;/h3&gt;
&lt;ul&gt;
&lt;li&gt;Experience with PHP, ColdFusion, Farcry CMS, XML, Web Standards etc&lt;/li&gt;
&lt;li&gt;Competency using linux-based tools (SSH, bash, etc)&lt;/li&gt;
&lt;li&gt;Familiar with using source control tools (Subversion, etc)&lt;/li&gt;
&lt;li&gt;Familiarity with Actionscript or Flash&lt;/li&gt;
&lt;/ul&gt;

This role may be full time, part-time or on a contract basis depending on the candidates skills and experience. You will be working in a casual workplace with flexible hours in the centre of Sydney.

If this sounds like the job for you email your resume to mark@lynchconsulting.com.au if interested - no agencies please.
				
				</description>
				
				<category>Learnosity</category>
				
				<category>Jobs</category>
				
				<category>Java</category>
				
				<category>General</category>
				
				<category>Flex</category>
				
				<category>ColdFusion</category>
				
				<category>Asterisk</category>
				
				<category>AIR</category>
				
				<category>Actionscript</category>
				
				<category>PHP</category>
				
				<pubDate>Fri, 09 May 2008 00:17:00 --1000</pubDate>
				<guid>http://www.lynchconsulting.com.au/blog/index.cfm/2008/5/9/Job-Vacancy-Sydney-AU--Graduate-or-Junior-OO-Programmer</guid>
				
			</item>
			
		 	
			</channel></rss>