<?xml version="1.0" encoding="UTF-8"?>
<?xml-stylesheet type="text/xsl" media="screen" href="/~d/styles/atom10full.xsl"?><?xml-stylesheet type="text/css" media="screen" href="http://feeds.feedburner.com/~d/styles/itemcontent.css"?><feed xmlns="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:thr="http://purl.org/syndication/thread/1.0" xmlns:feedburner="http://rssnamespace.org/feedburner/ext/1.0">
    <title>On The Other Hand...</title>
    
    
    <link rel="alternate" type="text/html" href="http://otoh.typepad.com/on_the_other_hand/" />
    <id>tag:typepad.com,2003:weblog-1663392</id>
    <updated>2009-07-05T17:58:09-04:00</updated>
    
    <generator uri="http://www.typepad.com/">TypePad</generator>
    <atom10:link xmlns:atom10="http://www.w3.org/2005/Atom" rel="self" type="application/atom+xml" href="http://feeds.feedburner.com/typepad/1212670151s5517/on_the_other_hand" /><feedburner:info uri="typepad/1212670151s5517/on_the_other_hand" /><atom10:link xmlns:atom10="http://www.w3.org/2005/Atom" rel="hub" href="http://pubsubhubbub.appspot.com/" /><atom10:link xmlns:atom10="http://www.w3.org/2005/Atom" rel="hub" href="http://hubbub.api.typepad.com/" /><entry>
        <title>Anonymous Coding</title>
        <link rel="alternate" type="text/html" href="http://feedproxy.google.com/~r/typepad/1212670151s5517/on_the_other_hand/~3/Zl1k3P1R6o0/anonymous-coding.html" />
        <link rel="replies" type="text/html" href="http://otoh.typepad.com/on_the_other_hand/2009/07/anonymous-coding.html" thr:count="0" />
        <id>tag:typepad.com,2003:post-63438339</id>
        <published>2009-07-05T17:58:09-04:00</published>
        <updated>2009-07-05T17:58:09-04:00</updated>
        <summary>If you are looking for a good programming font, check out anonymous. Anonymous is a fixed width, sans font from Mark Simonson "designed especially for coders". It's copyrighted, but is free to use and worth a look.</summary>
        <author>
            <name>Garth Somerville</name>
        </author>
        <category scheme="http://www.sixapart.com/ns/types#category" term="Programming" />
        
        
<content type="xhtml" xml:lang="en-US" xml:base="http://otoh.typepad.com/on_the_other_hand/">
<div xmlns="http://www.w3.org/1999/xhtml"><p>If you are looking for a good programming font, check out <a href="http://www.ms-studio.com/FontSales/anonymous.html" title="Programming Font">anonymous</a>.  Anonymous is a fixed width, sans font from Mark Simonson "designed especially for coders".  It's copyrighted, but is free to use and worth a look.</p><p><br /><a href="http://otoh.typepad.com/.a/6a00e552badf4c88330111689d549d970c-popup" onclick="window.open( this.href, '_blank', 'width=640,height=480,scrollbars=no,resizable=no,toolbar=no,directories=no,location=no,menubar=no,status=no,left=0,top=0' ); return false" style="display: inline;"><img alt="Anonymous" class="at-xid-6a00e552badf4c88330111689d549d970c " src="http://otoh.typepad.com/.a/6a00e552badf4c88330111689d549d970c-500wi" /></a>
 </p></div>
</content>



    <feedburner:origLink>http://otoh.typepad.com/on_the_other_hand/2009/07/anonymous-coding.html</feedburner:origLink></entry>
    <entry>
        <title>Lefty List</title>
        <link rel="alternate" type="text/html" href="http://feedproxy.google.com/~r/typepad/1212670151s5517/on_the_other_hand/~3/ucDoUvfZhNA/lefty-list.html" />
        <link rel="replies" type="text/html" href="http://otoh.typepad.com/on_the_other_hand/2009/03/lefty-list.html" thr:count="0" />
        <id>tag:typepad.com,2003:post-63442805</id>
        <published>2009-03-02T19:41:45-05:00</published>
        <updated>2009-03-02T19:41:17-05:00</updated>
        <summary>In the category of the somewhat strange, what if you need to place a scroll bar on the left side of a Flex component? Or maybe you need a horizontal scroll bar at top instead of the bottom of a...</summary>
        <author>
            <name>Garth Somerville</name>
        </author>
        <category scheme="http://www.sixapart.com/ns/types#category" term="Flex" />
        
        
<content type="xhtml" xml:lang="en-US" xml:base="http://otoh.typepad.com/on_the_other_hand/">
<div xmlns="http://www.w3.org/1999/xhtml"><p>In the category of the <em>somewhat strange</em>, what if you need to place a scroll bar on the left side of a Flex component?  Or maybe you need a horizontal scroll bar at top instead of the bottom of a list? It is almost, but not quite, as simple as overriding updateDisplayList and moving the scroll bar, as I have seen <a href="http://yourpalmark.com/2008/06/18/reposition-scrollbars-in-flex-components/">mentioned</a> elsewhere.  </p><p>What is easy to miss is the effect on the <strong>viewMetrics</strong> property of ScrollControlBase.  The viewMetrics is simply a <strong>borderMetrics</strong> that also accounts for the space used by any visible scrollbars.  If you move the scrollbars you must also recalculate the view metrics to accurately account for their new positions.  </p><p>The Flex 3 controls have hardcoded logic for scrollbars on the right and bottom, but placing them on the left or top is so easy it should really just be a matter of setting a style.  The demo below does exactly that.  </p><p>It uses a derived List class that adds two new styles --  <em>horizontalScrollSide</em> can be set to "top" or "bottom," and <em>verticalScrollSide</em> can be set to "left" or "right."  The demo also shows the difference between the borderMetrics and viewMetrics using the radio buttons at the bottom.</p><p>Right-click to view or download the source code.</p>

<center>
 	<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://fpdownload.macromedia.com/get/flashplayer/current/swflash.cab" height="540" id="LeftyList" width="300">
			<param name="movie" value="http://otoh.typepad.com/on_the_other_hand/files/lefty-list/LeftyList.swf" />
			<param name="quality" value="high" />
			<param name="bgcolor" value="#869ca7" />
			<param name="allowScriptAccess" value="sameDomain" />
			<embed align="middle" allowscriptaccess="sameDomain" bgcolor="#869ca7" height="540" loop="false" name="LeftyList" play="true" pluginspage="http://www.adobe.com/go/getflashplayer" quality="high" src="http://otoh.typepad.com/on_the_other_hand/files/lefty-list/LeftyList.swf" type="application/x-shockwave-flash" width="300" />
			
	</object>
</center></div>
</content>



    <feedburner:origLink>http://otoh.typepad.com/on_the_other_hand/2009/03/lefty-list.html</feedburner:origLink></entry>
    <entry>
        <title>Tune Your Flex Builder Java VM Settings</title>
        <link rel="alternate" type="text/html" href="http://feedproxy.google.com/~r/typepad/1212670151s5517/on_the_other_hand/~3/g7LSy2W_xpI/tune-your-flex.html" />
        <link rel="replies" type="text/html" href="http://otoh.typepad.com/on_the_other_hand/2008/06/tune-your-flex.html" thr:count="0" />
        <id>tag:typepad.com,2003:post-51593894</id>
        <published>2008-06-19T15:58:05-04:00</published>
        <updated>2008-06-19T15:58:05-04:00</updated>
        <summary>Have you ever suffered from constant pauses in the IDE while using Flex Builder? The default memory and garbage collection choices can, depending on your setup, end up leading to relentless garbage collection that leaves you with the feeling of...</summary>
        <author>
            <name>Garth Somerville</name>
        </author>
        <category scheme="http://www.sixapart.com/ns/types#category" term="Flex" />
        
        
<content type="html" xml:lang="en-US" xml:base="http://otoh.typepad.com/on_the_other_hand/">
&lt;div xmlns="http://www.w3.org/1999/xhtml"&gt;&lt;p&gt;Have you ever suffered from constant pauses in the IDE while using Flex Builder?&amp;nbsp; &amp;nbsp;The default memory and garbage collection choices can, depending on your setup, end up leading to relentless garbage collection that leaves you with the feeling of playing a first person shooter at about ten frames per second.&amp;nbsp; It makes productive development impossible, but fortunately you can almost certainly fix it by tuning the JVM options found in the file flexbuilder.ini in the directory where you installed Flex Builder.&lt;/p&gt;

&lt;p&gt;To begin you can check your current environment in Flex Builder by choosing Help -&amp;gt; Product Details -&amp;gt; Configuration Details.&lt;/p&gt;

&lt;p&gt;The first thing you might notice is that Flex Builder is running with a JRE 1.5 located in the [jre] directory where Flex Builder is installed, even though as a developer you have the latest 1.6 JRE installed on your system.&amp;nbsp; If you want to run under 1.6, I believe the easiest was to do it is to simply remain the [jre] directory to [this-is-not-a-jre] and restart Flex Builder, which will now run using the default JRE on your system.&amp;nbsp; You can point to a specific JRE on your system, but make sure that Eclipse is actually using that JRE -- see the comments &lt;a href="http://renaun.com/blog/2006/06/27/50/"&gt;here&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;Next you can change the garbage collection and memory settings by editing the file flexbuilder.ini.&amp;nbsp; By default, these settings probably look like this:&lt;/p&gt;

&lt;pre&gt;-Xms128m&lt;br /&gt;-Xmx512m&lt;br /&gt;-XX:MaxPermSize=256m&lt;br /&gt;-XX:PermSize=64m&lt;/pre&gt;

&lt;p&gt;Using the &lt;a href="http://java.sun.com/docs/hotspot/gc5.0/gc_tuning_5.html#1.1.Sizing%20the%20Generations%7Coutline"&gt;Garbage Collection Tuning&lt;/a&gt; documentation as your guide, try different settings to improve the responsiveness of the IDE.&amp;nbsp; Since developers' systems, and even the way we use Flex Builder, are different, there is no one choice of settings that is optimal for everyone.&amp;nbsp; However, a few points may hold true:&lt;/p&gt;

&lt;ul&gt;&lt;li&gt;Use a larger heap size if you can.&amp;nbsp; More memory is the easiest way to achieve fewer full collections ;-)&lt;/li&gt;

&lt;li&gt;Use a relatively larger tenured collection than the default settings provide.&lt;/li&gt;

&lt;li&gt;A couple of seconds added to compile time is barely noticeable, but constant virtual &amp;quot;screen freezes&amp;quot; while you are typing code or working in the IDE is fatal to your work flow as a developer.&amp;nbsp; Therefore, I have a strong preference for the low pause garbage collector over the throughput collector.&lt;/li&gt;&lt;/ul&gt;

&lt;p&gt;In my case, on an Athlon X2 machine with 2GB of memory I found the following settings give excellent performance without evidence of full collections taking place and, most importantly, have eliminated any hint of constant pauses while using Flex Builder.&lt;/p&gt;



&lt;pre&gt;-XX:+UseConcMarkSweepGC&lt;br /&gt;-XX:+CMSIncrementalMode&lt;br /&gt;-XX:NewRatio=3&lt;br /&gt;-Xmx640m&lt;br /&gt;&lt;br /&gt;&lt;/pre&gt;

&lt;p&gt;Once you have the JVM garbage collection under control, Flex Builder is a joy to use.&lt;/p&gt;&lt;/div&gt;
</content>



    <feedburner:origLink>http://otoh.typepad.com/on_the_other_hand/2008/06/tune-your-flex.html</feedburner:origLink></entry>
    <entry>
        <title>Embed The YouTube Chromeless Player In Your Flex Application</title>
        <link rel="alternate" type="text/html" href="http://feedproxy.google.com/~r/typepad/1212670151s5517/on_the_other_hand/~3/eVSFdDvjW7s/embed-the-youtu.html" />
        <link rel="replies" type="text/html" href="http://otoh.typepad.com/on_the_other_hand/2008/06/embed-the-youtu.html" thr:count="40" thr:updated="2010-12-23T19:33:36-05:00" />
        <id>tag:typepad.com,2003:post-50975062</id>
        <published>2008-06-08T17:23:45-04:00</published>
        <updated>2009-03-01T14:54:43-05:00</updated>
        <summary>Update Feb 27, 2009 This article generated a lot of interest. The most common complaint has been that the example doesn't work if you open it in multiple browser windows. This is a consequence of using a LocalConnection with a...</summary>
        <author>
            <name>Garth Somerville</name>
        </author>
        <category scheme="http://www.sixapart.com/ns/types#category" term="Flex" />
        
        
<content type="xhtml" xml:lang="en-US" xml:base="http://otoh.typepad.com/on_the_other_hand/">
<div xmlns="http://www.w3.org/1999/xhtml"><p><strong>Update Feb 27, 2009</strong>
<br />This article generated a lot of interest. The most common complaint has been that the example doesn't work if you open it in multiple browser windows. This is a consequence of using a LocalConnection with a fixed name to receive incoming messages from the wrapper -- a second instance of the demo tries, and fails, to create the same LocalConnection. This is now fixed. I also reworked YTPlayer as a simple AS3 class instead of an MXML component.

If you are trying to use this class in an AIR application, expect some difficulty! I hope to address this later, but for now please have a look at Chris Black's <a href="http://www.blackcj.com/blog/tag/chromeless-player/">article</a> showing an alternative approach that uses AIR's HTML control to embed the player and communicate via the YouTUbe Javascript APIs. In fact, the same approach can be used in the browser so long as you have script access. 




</p><p>The following is the original article.</p><h2>Embed The YouTube Chromeless Player In Your Flex Application</h2><p>Part of the success of Adobe Flex is due to the fact that it makes
development for Flash recognizable and readily accessible to mainstream
C++ and Java application developers who never programmed for Flash
before.  But development can come to a screeching halt when confronted
with something as simple as integration of a legacy Flash component. 
Embedding the YouTube chromeless player, written in AS2, in a Flex
application is a good example.  How does a Flex developer pull this off
with no prior knowledge of AS2 or Flash Authoring, and without a copy
of CS3 anywhere in sight? </p>

<p><strong><span style="font-size: 1.2em;">Some Background</span></strong></p>

<p>For this article we are only concerned with playing a YouTube video in a Flex application using the <a href="http://code.google.com/apis/youtube/chromeless_player_reference.html">chromeless player API</a>.  We will not be using the YouTube <a href="http://code.google.com/apis/youtube/developers_guide_protocol.html">Data APIs</a>, so our starting assumption is that we already have the ID of any video we want to play.</p>

<p>There are three ways to playback YouTube video.  You could embed the stock YouTube player using a URL of the form http://www.youtube.com/v/VIDEO_ID  but you will not be able to control or interact with the player SWF at all.  Secondly, you could access the FLV files directly and play them with the Flex VideoDisplay control.  You'll need to <a href="http://www.abdulqabiz.com/blog/archives/flash_and_actionscript/constructing_youtube_1.php">construct the URL</a> to the FLV.  See <a href="http://www.jamesward.org/">James Ward's</a> impressive <a href="http://www.jamesward.org/wordpress/2008/03/11/new-flex-screencast-and-videocoverflow-component/">demo</a> using <a href="http://www.jamesward.org/wordpress/2008/03/11/new-flex-screencast-and-videocoverflow-component/">Dough McCune’s cover flow component</a>.  Note that to play the FLVs directly you will end up proxying or storing them on your own server.</p>

<p>The third option, and the one we are interested in, is to embed the YouTube chromeless player, located at http://gdata.youtube.com/apiplayer.  The advantages of this player are:</p>

<ul>
<li>It allows full programmatic control over loading and playback. </li>
<li>It can be used without a proxy thanks to the presence of a crossdomain.xml at gdata.youtube.com.</li>
<li>As the name implies, you can skin the player in any way you like.</li>
</ul>

<p>The catch using this with Flex is that the YouTube player is written in AS2.  While there is no issue loading the AS2 SWF in your Flex app, you cannot interact with it from your AS3 code.  The <a href="http://jessewarden.com/2007/05/controlling-flash-player-8-swfs-in-flash-player-9-swfs.html">solution</a> to this problem is to write a wrapper SWF <em>in AS2</em> and use LocalConnection objects to enable two-way communication between the AS2 code and your Flex application.  </p>

<p>A basic outline of this approach was <a href="http://groups.google.com/group/youtube-api-gdata/browse_thread/thread/3c98068961296b38/07ecb5ee1168cefb?lnk=gst">posted </a>on March 17th on the YouTube developer forum.  Still, a Flex-only developer with no tools other than Flex Builder might feel no closer to a solution with this code. At least one developer on the forums was lead to practically <a href="http://groups.google.com/group/youtube-api-gdata/browse_thread/thread/9126e690016f1659/63ce800e637fc9b0?lnk=gst&amp;q=as3#63ce800e637fc9b0">beg for help </a>from the AS2/Flash developers.</p>

<p><strong><span style="font-size: 1.2em;">Writing The AS2 Wrapper</span></strong></p>

<p>First, to use the chromeless player you must have a YouTube Developer key and you <strong>must</strong> pass the key as a query argument in the player URL.  It only takes a minute to sign up <a href="http://code.google.com/apis/youtube/dashboard/">here</a>.</p>

<p>The wrapper follows the same outline as the AS2 code posted in the YouTube developer forums with a few changes.  First we are going to use a pair of LocalConnection objects for each instance of the embedded player to enable bi-directional communication.  This is required if we want to deliver player status-change events and the current playback position to our Flex application.  Secondly, we will give each instance of the embedded player a different name -- hopefully the code will support multiple embedded players.</p>

<p>The communication looks like this:</p>

<center><a href="http://otoh.typepad.com/photos/uncategorized/2008/06/08/structure.jpg"><img alt="Structure" border="1" src="http://otoh.typepad.com/photos/uncategorized/2008/06/08/structure.jpg" title="Structure" /></a></center>

<br />

<p>The Flex code will use one LocalConnection with a fixed name to receive from the wrapper the randomly generated instance name of each player instance.  Using this name, a pair of additional LocalConnection objects is created -- one for Flex to issue commands that control the player, and one for the wrapper to send status updates to Flex.</p>

<p><strong><span style="font-size: 1.2em;">Building The Wrapper Without CS3</span></strong>

</p>

<p>We can use <a href="http://swfmill.org/">swfmill</a> and <a href="http://www.mtasc.org/">MTASC</a> to build the wrapper without using CS3.  Both are very simple to use and Clemans Hofreither posted a nice <a href="http://osflash.org/projectsetup">tutorial</a> about using these two programs together.  The result is a ytbridge.swf that we can deploy with our Flex application, and we don't need a copy of CS3.  The full source for the wrapper and the commands used to build it are included in the source ZIP with the Flex demo below so I'm not reposting it here.  </p>

<p>Because the required developer key is passed from Flex to the wrapper, you are not required to build ytbridge.swf yourself unless you are making changes to the wrapper.  If you want, you can simply take ytbridge.swf as is from the source ZIP and avoid this step completely.</p>

<p><strong><span style="font-size: 1.2em;">Using The Wrapper from Flex</span></strong></p>

<p>All that remains is to load ytbridge.swf in our Flex application and communicate with it via the  LocalConnection objects.  Rather than walk through the details here, just choose View Source on the Flex demo.  Click on the image below to view the demo.</p><br />

<center><a href="http://otoh.typepad.com/on_the_other_hand/files/flex-youtube/YouTubeTest.html"><img alt="Screenshot" border="1" src="http://otoh.typepad.com/photos/uncategorized/2008/06/08/screenshot.png" title="Screenshot" /></a>
</center><br /><p><span style="font-size: 1.2em;">Other comments:</span></p>

<ul>
<li>I am not a Flash/AS2 developer.  If anyone can help improve or make corrections to the wrapper, please help!  Otherwise, feel free to use this as is at your own risk.</li>
<li>You can create multiple instances of YTPlayer in your Flex app, but it seems you must load a video into each one before creating another.  Also, I had trouble separately controlling volume in any except the last player instance created.</li>
<li>If you are finished with a player instance you <strong>must</strong> call dispose() in order to have the best chance of actually stopping audio and video playback and reclaiming resources.</li>
<li>You can resize the player without difficulty as the demo shows, but you should ensure that the player maintains an aspect ratio of 4:3.</li>
<li>Don't forget to pass your developer key -- it will not work without it.</li>
</ul></div>
</content>



    <feedburner:origLink>http://otoh.typepad.com/on_the_other_hand/2008/06/embed-the-youtu.html</feedburner:origLink></entry>
 
</feed><!-- ph=1 -->

