<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>computers should be less friendly &#187; Flex</title>
	<atom:link href="http://blog.danmcweeney.com/category/flex/feed" rel="self" type="application/rss+xml" />
	<link>http://blog.danmcweeney.com</link>
	<description></description>
	<lastBuildDate>Mon, 10 Aug 2009 20:38:22 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.2.1</generator>
		<item>
		<title>Some Useful Flex/AIR Tidbits</title>
		<link>http://blog.danmcweeney.com/69</link>
		<comments>http://blog.danmcweeney.com/69#comments</comments>
		<pubDate>Tue, 22 Apr 2008 14:03:21 +0000</pubDate>
		<dc:creator>dan</dc:creator>
				<category><![CDATA[Adobe]]></category>
		<category><![CDATA[AIR]]></category>
		<category><![CDATA[Flex]]></category>

		<guid isPermaLink="false">http://blog.danmcweeney.com/69</guid>
		<description><![CDATA[Recently I had the &#8220;pleasure&#8221; of learning the ins and outs of building Flex and AIR applications via the SDK on a Linux machine.&#160; I wanted to do this for some of the libraries that underpin my project so that they could be built and tested automatically.&#160; So, I setup SVN, Trac and CruiseControl on [...]]]></description>
			<content:encoded><![CDATA[<p>Recently I had the &#8220;pleasure&#8221; of learning the ins and outs of building Flex and AIR applications via the SDK on a Linux machine.&nbsp; I wanted to do this for some of the libraries that underpin my project so that they could be built and tested automatically.&nbsp; So, I setup SVN, Trac and CruiseControl on a Ubuntu VM on my mac.&nbsp; To get started there are tons of resources about getting SVN and Trac setup under Apache on Ubuntu so, just Google for them.&nbsp; Setting up CruiseControl was really easy thanks to their good documents, I started with the source distro but, do whatever works.</p>
<p>Now, onto why I&#8217;m posting today, along the way I found some annoying things about how FlexBuilder played with the SDK.&nbsp; For instance, the .flexLibProperties file that is hidden in your FB project, is not the right format to be taken in as a parameter to &#8220;compc&#8221; ( the library compiler, which seems to require a list of class names to include ), so I wrote a quick Python script to convert that file into a config file that is readable by compc.&nbsp; Here is how to include it in your Ant script:</p>
<div style="border-right: gray 1px solid; padding-right: 4px; border-top: gray 1px solid; padding-left: 4px; font-size: 8pt; padding-bottom: 4px; margin: 20px 0px 10px; overflow: auto; border-left: gray 1px solid; width: 97.5%; cursor: text; max-height: 300px; line-height: 12pt; padding-top: 4px; border-bottom: gray 1px solid; font-family: consolas, 'Courier New', courier, monospace; background-color: #f4f4f4">
<pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none">

<span style="color: #0000ff">&lt;</span><span style="color: #800000">target</span> <span style="color: #ff0000">name</span><span style="color: #0000ff">="setupClassList"</span><span style="color: #0000ff">&gt;</span>
    <span style="color: #0000ff">&lt;</span><span style="color: #800000">exec</span> <span style="color: #ff0000">executable</span><span style="color: #0000ff">="python"</span> <span style="color: #ff0000">failonerror</span><span style="color: #0000ff">="yes"</span><span style="color: #0000ff">&gt;</span>
        <span style="color: #0000ff">&lt;</span><span style="color: #800000">arg</span> <span style="color: #ff0000">line</span><span style="color: #0000ff">="${helperDir}/classFileConverter.py ${lib_root_dir}/.flexLibProperties classes.xml"</span><span style="color: #0000ff">/&gt;</span>
    <span style="color: #0000ff">&lt;/</span><span style="color: #800000">exec</span><span style="color: #0000ff">&gt;</span>
<span style="color: #0000ff">&lt;/</span><span style="color: #800000">target</span><span style="color: #0000ff">&gt;</span>


&nbsp;
</pre>
</div>
<p>It takes in two parameters so you can manipulate the output location of the new file.<br />Another odd part is that the application descriptor for an AIR project doesn&#8217;t get correctly populated.&nbsp; FB itself fills in the &lt;content&gt; tag for you when it goes to compile.&nbsp; If you look in your source directory the application descriptor has this string, &#8220;[This value will be overwritten by Flex Builder in the output app.xml]&#8221; instead of the name of the SWF.&nbsp; One more little python script:</p>
<div style="border-right: gray 1px solid; padding-right: 4px; border-top: gray 1px solid; padding-left: 4px; font-size: 8pt; padding-bottom: 4px; margin: 20px 0px 10px; overflow: auto; border-left: gray 1px solid; width: 97.5%; cursor: text; max-height: 300px; line-height: 12pt; padding-top: 4px; border-bottom: gray 1px solid; font-family: consolas, 'Courier New', courier, monospace; background-color: #f4f4f4">
<pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none">

<span style="color: #0000ff">&lt;</span><span style="color: #800000">exec</span> <span style="color: #ff0000">executable</span><span style="color: #0000ff">="python"</span> <span style="color: #ff0000">failonerror</span><span style="color: #0000ff">="yes"</span><span style="color: #0000ff">&gt;</span>
    <span style="color: #0000ff">&lt;</span><span style="color: #800000">arg</span> <span style="color: #ff0000">line</span><span style="color: #0000ff">="${helperDir}/appDescrFix.py ../bin-debug/${app_descriptor}"</span><span style="color: #0000ff">/&gt;</span>
<span style="color: #0000ff">&lt;/</span><span style="color: #800000">exec</span><span style="color: #0000ff">&gt;</span>

<span style="color: #0000ff"></span><font color="#0000ff"></font>

</pre>
</div>
<p>&nbsp;</p>
<p>Of course, I am going to give you the scripts!&nbsp; Here are the links:<br /><a href="http://www.danmcweeney.com/static/mxmlcHelpers/classFileConverter.py">.flexLibProperties Converter</a><br /><a href="http://www.danmcweeney.com/static/mxmlcHelpers/appDescrFix.py">Application Descriptor Fixer</a></p>
<p>&nbsp;</p>
<p>If someone knows a much easier way to do this just using the command line tools and/or Ant, I&#8217;d love to hear it!</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.danmcweeney.com/69/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>SAP Web Services in Flex Builder</title>
		<link>http://blog.danmcweeney.com/57</link>
		<comments>http://blog.danmcweeney.com/57#comments</comments>
		<pubDate>Wed, 14 Nov 2007 19:52:43 +0000</pubDate>
		<dc:creator>dan</dc:creator>
				<category><![CDATA[ABAP]]></category>
		<category><![CDATA[Flex]]></category>
		<category><![CDATA[SDN blogger]]></category>

		<guid isPermaLink="false">http://blog.danmcweeney.com/57</guid>
		<description><![CDATA[SAP web services are really complex, tables inside rows inside tables inside structures.&#160; I&#8217;ve been fielding an increasing number of questions about using these in the forum so, instead of answering everyone separately here are a few examples from simple to complex. Let&#8217;s start off with one of the simpler examples just to get the [...]]]></description>
			<content:encoded><![CDATA[<p>SAP web services are really complex, tables inside rows inside tables inside structures.&nbsp; I&#8217;ve been fielding an increasing number of questions about using these in the forum so, instead of answering everyone separately here are a few examples from simple to complex.</p>
<p>Let&#8217;s start off with one of the simpler examples just to get the hang of it.&nbsp; Use SAPLink and install this <a href="http://zclguialvgrid.googlecode.com/files/FUGR_ZSDN_TESTS.slnk">function group</a> and generate a web service from the one function in it.&nbsp; Now, lets write some Flex code to call this.</p>
<h3>Import Statements</h3>
<p>A few people have asked me to add the import statements to this.&nbsp; For reference if you go to the object that has the error, move your cursor to the end of the word hold control and press space the import will be added for you automatically, welcome to the wonderful world of a good IDE.&nbsp; But the following in a &lt;mx:Script&gt; block between the &lt;mx:Application&gt; tags.</p>
<div class="wlWriterEditableSmartContent" id="57F11A72-B0E5-49c7-9094-E3A15BD5B5E6:cfad4a30-9b29-416c-93d9-133e8c4b2b76" contenteditable="false" style="padding-right: 0px; display: inline; padding-left: 0px; float: none; padding-bottom: 0px; margin: 0px; padding-top: 0px">
<pre style="background-color: white">
<div><!--

Code highlighting produced by Actipro CodeHighlighter (freeware)

http://www.CodeHighlighter.com/

--><span style="color: #000000">import mx.rpc.AbstractOperation;
import mx.rpc.events.FaultEvent;
import mx.rpc.events.ResultEvent;
import mx.rpc.soap.LoadEvent;
import mx.rpc.soap.WebService;</span></div>
</pre>
</div>
<h2>Simplest Example</h2>
<h3>Step 1 &#8211; Get your WSDL</h3>
<div class="wlWriterSmartContent" id="57F11A72-B0E5-49c7-9094-E3A15BD5B5E6:177a0323-a5da-495a-b187-ee5972c3502e" contenteditable="false" style="padding-right: 0px; display: inline; padding-left: 0px; float: none; padding-bottom: 0px; margin: 0px; width: 703px; padding-top: 0px">
<pre style="background-color:White;white-space:-moz-pre-wrap; white-space: -pre-wrap; white-space: -o-pre-wrap; white-space: pre-wrap; word-wrap: break-word;">
<div><!--

Code highlighting produced by Actipro CodeHighlighter (freeware)

http://www.CodeHighlighter.com/

--><span style="color: #008080; ">1</span> <span style="color: #0000FF; ">private</span><span style="color: #000000; "> function callWebService():</span><span style="color: #0000FF; ">void</span><span style="color: #000000; ">{
</span><span style="color: #008080; ">2</span> <span style="color: #000000; ">    fooService </span><span style="color: #000000; ">=</span><span style="color: #000000; "> </span><span style="color: #0000FF; ">new</span><span style="color: #000000; "> WebService();
</span><span style="color: #008080; ">3</span> <span style="color: #000000; ">    fooService.wsdl </span><span style="color: #000000; ">=</span><span style="color: #000000; "> </span><span style="color: #000000; ">&quot;</span><span style="color: #000000; ">http://localhost/sap/bc/srt/rfc/sap/Z_TEST_CHANGING_PARAM?sap-client=300&amp;wsdl=1.1</span><span style="color: #000000; ">&quot;</span><span style="color: #000000; ">;
</span><span style="color: #008080; ">4</span> <span style="color: #000000; ">    fooService.addEventListener(LoadEvent.LOAD, loadListener);
</span><span style="color: #008080; ">5</span> <span style="color: #000000; ">    fooService.addEventListener(ResultEvent.RESULT, resultTrigger);
</span><span style="color: #008080; ">6</span> <span style="color: #000000; ">    fooService.addEventListener(FaultEvent.FAULT,fault);
</span><span style="color: #008080; ">7</span> <span style="color: #000000; ">    fooService.loadWSDL();
</span><span style="color: #008080; ">8</span> <span style="color: #000000; ">}</span></div>
</pre>
</div>
<p><strong>Line by Line:</strong></p>
<ol>
<li>Declare a function that will start the whole process</li>
<li>Create a WebService object, this should be global or at least visible to the other methods ( you&#8217;ll need it later )</li>
<li>Point the WS to the location of the WSDL</li>
<li>Add an EventListener for when the Loading of the WSDL is complete</li>
<li>Add an EventListener for the results coming back from the call</li>
<li>Add an EventListener for any errors that occur</li>
<li>Tell the WS to load the WSDL</li>
</ol>
<h3><font face="Verdana">Step 2 &#8211; Set Some Parameters</font></h3>
<p><div class="wlWriterSmartContent" id="57F11A72-B0E5-49c7-9094-E3A15BD5B5E6:438555d6-8ee2-4317-b461-6b80d6189730" contenteditable="false" style="padding-right: 0px; display: inline; padding-left: 0px; float: none; padding-bottom: 0px; margin: 0px; width: 694px; padding-top: 0px">
<pre style="background-color:White;white-space:-moz-pre-wrap; white-space: -pre-wrap; white-space: -o-pre-wrap; white-space: pre-wrap; word-wrap: break-word;">
<div><!--

Code highlighting produced by Actipro CodeHighlighter (freeware)

http://www.CodeHighlighter.com/

--><span style="color: #008080; ">1</span> <span style="color: #0000FF; ">private</span><span style="color: #000000; "> function loadListener(</span><span style="color: #0000FF; ">event</span><span style="color: #000000; ">:LoadEvent):</span><span style="color: #0000FF; ">void</span><span style="color: #000000; ">{
</span><span style="color: #008080; ">2</span> <span style="color: #000000; ">    var op:AbstractOperation </span><span style="color: #000000; ">=</span><span style="color: #000000; "> fooService.getOperation(</span><span style="color: #000000; ">&quot;</span><span style="color: #000000; ">Z_DOUBLE_ROWS</span><span style="color: #000000; ">&quot;</span><span style="color: #000000; ">);
</span><span style="color: #008080; ">3</span> <span style="color: #000000; ">    var input:Object </span><span style="color: #000000; ">=</span><span style="color: #000000; "> </span><span style="color: #0000FF; ">new</span><span style="color: #000000; "> Object();
</span><span style="color: #008080; ">4</span> <span style="color: #000000; ">    input.TEST </span><span style="color: #000000; ">=</span><span style="color: #000000; "> </span><span style="color: #0000FF; ">new</span><span style="color: #000000; "> Array();
</span><span style="color: #008080; ">5</span> <span style="color: #000000; ">    input.TEST.push(</span><span style="color: #000000; ">&quot;</span><span style="color: #000000; ">foo</span><span style="color: #000000; ">&quot;</span><span style="color: #000000; ">);
</span><span style="color: #008080; ">6</span> <span style="color: #000000; ">    input.TEST.push(</span><span style="color: #000000; ">&quot;</span><span style="color: #000000; ">bar</span><span style="color: #000000; ">&quot;</span><span style="color: #000000; ">);
</span><span style="color: #008080; ">7</span> <span style="color: #000000; ">    op.arguments </span><span style="color: #000000; ">=</span><span style="color: #000000; "> input;
</span><span style="color: #008080; ">8</span> <span style="color: #000000; ">    op.send();
</span><span style="color: #008080; ">9</span> <span style="color: #000000; ">}</span></div>
</pre>
</div>
<p><strong>Line by Line:</strong></p>
<ol>
<li>Declare a function who handles the event you subscribed to in the Step&nbsp;1 line 4.</li>
<li>Get the Operation from the WSDL file.&nbsp; This is one of those &#8220;standard&#8221; ways of doing things.&nbsp; If you look at your WSDL file you will see that it could have more then one operation in it, this gets the particular operation you want to call.</li>
<li>Create a dynamic object that will hold the inbound parameters to your WS.&nbsp; In this case the parameter TEST is a table of strings.</li>
<li>Here we create what Flex builder thinks is how to hold&nbsp; a table, an Array.</li>
<li>Then we push each &#8220;row&#8221; of the table into the array again, in this case it&#8217;s just one string at a time.</li>
<li>See Line 5</li>
<li>We then map the input object to the arguments of the WS.</li>
<li>Send our request including all the input data to the server</li>
</ol>
<h3>Step 3 &#8211; Look at the Output</h3>
<p><div class="wlWriterSmartContent" id="57F11A72-B0E5-49c7-9094-E3A15BD5B5E6:d2cd3332-1cb8-4784-b329-fe14eb61a44c" contenteditable="false" style="padding-right: 0px; display: inline; padding-left: 0px; float: none; padding-bottom: 0px; margin: 0px; width: 694px; padding-top: 0px">
<pre style="background-color:White;white-space:-moz-pre-wrap; white-space: -pre-wrap; white-space: -o-pre-wrap; white-space: pre-wrap; word-wrap: break-word;">
<div><!--

Code highlighting produced by Actipro CodeHighlighter (freeware)

http://www.CodeHighlighter.com/

--><span style="color: #008080; ">1</span> <span style="color: #0000FF; ">private</span><span style="color: #000000; "> function resultTrigger(</span><span style="color: #0000FF; ">event</span><span style="color: #000000; ">:ResultEvent):</span><span style="color: #0000FF; ">void</span><span style="color: #000000; ">{
</span><span style="color: #008080; ">2</span> <span style="color: #000000; ">    var item:String;
</span><span style="color: #008080; ">3</span> <span style="color: #000000; ">    </span><span style="color: #0000FF; ">for</span><span style="color: #000000; "> each(item </span><span style="color: #0000FF; ">in</span><span style="color: #000000; "> </span><span style="color: #0000FF; ">event</span><span style="color: #000000; ">.result){
</span><span style="color: #008080; ">4</span> <span style="color: #000000; ">        trace(item);
</span><span style="color: #008080; ">5</span> <span style="color: #000000; ">    }
</span><span style="color: #008080; ">6</span> <span style="color: #000000; ">}</span></div>
</pre>
</div>
<p><strong>Line by Line</strong></p>
<ol>
<li>Define a function to handle the event from section 1 line 5</li>
<li>Declare on object to hold each result</li>
<li>Loop at each item in the result list, which happen to be strings.</li>
<li>Print them out to the debug console</li>
</ol>
<p>I will talk about more advanced parsing of the result set later on.</p>
<h2>Inbound Table Parameter</h2>
<p>First, get your WSDL, in this case I will be using the FM BAPI_FLIGHT_GETLIST from the SFLIGHTS example we are all so fond of.&nbsp; You should run this FM a few times to make sure you have data on the ABAP side, I will be passing in a date range to this FM so, you might want to find two dates that return some data for you. ( I named my WebService &#8220;Z_GET_FLIGHT_LIST&#8221; )</p>
<h3>Step 1 &#8211; Get Your WSDL</h3>
<p>This is the same exact thing you did before, just with a different WSDL.</p>
<h3>Step 2 &#8211; Set some Parameters</h3>
<p>There is a strange behavior with ABAP WebServices where if you have a table that is both Input and Output you must pass it as part request to get it filled.&nbsp; You&#8217;ll see in a second:</p>
<div class="wlWriterSmartContent" id="57F11A72-B0E5-49c7-9094-E3A15BD5B5E6:69c09289-32e6-49d6-bf4d-a6302ba552cb" contenteditable="false" style="padding-right: 0px; display: inline; padding-left: 0px; float: none; padding-bottom: 0px; margin: 0px; width: 697px; padding-top: 0px">
<pre style="background-color:White;white-space:-moz-pre-wrap; white-space: -pre-wrap; white-space: -o-pre-wrap; white-space: pre-wrap; word-wrap: break-word;">
<div><!--

Code highlighting produced by Actipro CodeHighlighter (freeware)

http://www.CodeHighlighter.com/

--><span style="color: #008080; ">1</span> <span style="color: #0000FF; ">private</span><span style="color: #000000; "> function loadListener(</span><span style="color: #0000FF; ">event</span><span style="color: #000000; ">:LoadEvent):</span><span style="color: #0000FF; ">void</span><span style="color: #000000; ">{
</span><span style="color: #008080; ">2</span> <span style="color: #000000; ">    var op:AbstractOperation </span><span style="color: #000000; ">=</span><span style="color: #000000; "> fooService.getOperation(</span><span style="color: #000000; ">&quot;</span><span style="color: #000000; ">BAPI_FLIGHT_GETLIST</span><span style="color: #000000; ">&quot;</span><span style="color: #000000; ">);
</span><span style="color: #008080; ">3</span> <span style="color: #000000; ">    var input:Object </span><span style="color: #000000; ">=</span><span style="color: #000000; "> </span><span style="color: #0000FF; ">new</span><span style="color: #000000; "> Object();
</span><span style="color: #008080; ">4</span> <span style="color: #000000; ">    input.FLIGHT_LIST </span><span style="color: #000000; ">=</span><span style="color: #000000; "> </span><span style="color: #0000FF; ">new</span><span style="color: #000000; "> Array();
</span><span style="color: #008080; ">5</span> <span style="color: #000000; ">    input.RETURN </span><span style="color: #000000; ">=</span><span style="color: #000000; "> </span><span style="color: #0000FF; ">new</span><span style="color: #000000; "> Array();
</span><span style="color: #008080; ">6</span> <span style="color: #000000; ">    op.arguments </span><span style="color: #000000; ">=</span><span style="color: #000000; "> input;
</span><span style="color: #008080; ">7</span> <span style="color: #000000; ">    op.send();
</span><span style="color: #008080; ">8</span> <span style="color: #000000; ">}</span></div>
</pre>
</div>
<p><strong>Line by Line</strong></p>
<ol>
<li>Define a function that handles the event</li>
<li>Get the right operation</li>
<li>Dynamic input object</li>
<li>You have to pass blank parameters to the WS so that the Web Application Server will fill them</li>
<li>See line 4</li>
<li>Same as last time</li>
<li>Same here</li>
</ol>
<p><strong><font face="Trebuchet MS"></font></strong></p>
<h3>Set Table Parameters</h3>
<div class="wlWriterSmartContent" id="57F11A72-B0E5-49c7-9094-E3A15BD5B5E6:aa159222-3442-4c18-aa83-e3ec8a1d1097" contenteditable="false" style="padding-right: 0px; display: inline; padding-left: 0px; float: none; padding-bottom: 0px; margin: 0px; width: 707px; padding-top: 0px">
<pre style="background-color:White;white-space:-moz-pre-wrap; white-space: -pre-wrap; white-space: -o-pre-wrap; white-space: pre-wrap; word-wrap: break-word;">
<div><!--

Code highlighting produced by Actipro CodeHighlighter (freeware)

http://www.CodeHighlighter.com/

--><span style="color: #008080; ">1</span> <span style="color: #000000; ">    var dateRangeRow:Object </span><span style="color: #000000; ">=</span><span style="color: #000000; "> </span><span style="color: #0000FF; ">new</span><span style="color: #000000; "> Object();
</span><span style="color: #008080; ">2</span> <span style="color: #000000; ">    input.DATE_RANGE </span><span style="color: #000000; ">=</span><span style="color: #000000; "> </span><span style="color: #0000FF; ">new</span><span style="color: #000000; "> Array();
</span><span style="color: #008080; ">3</span> <span style="color: #000000; ">    dateRangeRow.SIGN </span><span style="color: #000000; ">=</span><span style="color: #000000; "> </span><span style="color: #000000; ">&quot;</span><span style="color: #000000; ">I</span><span style="color: #000000; ">&quot;</span><span style="color: #000000; ">;
</span><span style="color: #008080; ">4</span> <span style="color: #000000; ">    dateRangeRow.OPTION </span><span style="color: #000000; ">=</span><span style="color: #000000; "> </span><span style="color: #000000; ">&quot;</span><span style="color: #000000; ">EQ</span><span style="color: #000000; ">&quot;</span><span style="color: #000000; ">;
</span><span style="color: #008080; ">5</span> <span style="color: #000000; ">    dateRangeRow.LOW </span><span style="color: #000000; ">=</span><span style="color: #000000; "> </span><span style="color: #000000; ">&quot;</span><span style="color: #000000; ">2002-12-20</span><span style="color: #000000; ">&quot;</span><span style="color: #000000; ">;
</span><span style="color: #008080; ">6</span> <span style="color: #000000; ">    dateRangeRow.HIGH </span><span style="color: #000000; ">=</span><span style="color: #000000; "> </span><span style="color: #000000; ">&quot;&quot;</span><span style="color: #000000; ">;
</span><span style="color: #008080; ">7</span> <span style="color: #000000; ">    input.DATE_RANGE.push(dateRangeRow);</span></div>
</pre>
</div>
<p><strong>Line by Line ( add this between lines 5 and 6 from the prior example )</strong></p>
<ol>
<li>Create a new dynamic object that holds a Row of the DATE_RANGE table</li>
<li>Create an array called DATE_RANGE which will map to the DATE_RANGE input parameter</li>
<li>Set each field dynamically</li>
<li>More fields</li>
<li>More fields</li>
<li>More fields ( don&#8217;t need to pass this one because it&#8217;s blank )</li>
<li>Push this row into the array</li>
</ol>
<h3>Step 3 &#8211; Look at the Output</h3>
<div class="wlWriterSmartContent" id="57F11A72-B0E5-49c7-9094-E3A15BD5B5E6:75a8b0ec-b550-49fc-b543-b28156dc611e" contenteditable="false" style="padding-right: 0px; display: inline; padding-left: 0px; float: none; padding-bottom: 0px; margin: 0px; width: 701px; padding-top: 0px">
<pre style="background-color:White;white-space:-moz-pre-wrap; white-space: -pre-wrap; white-space: -o-pre-wrap; white-space: pre-wrap; word-wrap: break-word;">
<div><!--

Code highlighting produced by Actipro CodeHighlighter (freeware)

http://www.CodeHighlighter.com/

--><span style="color: #008080; ">1</span> <span style="color: #0000FF; ">private</span><span style="color: #000000; "> function resultTrigger(</span><span style="color: #0000FF; ">event</span><span style="color: #000000; ">:ResultEvent):</span><span style="color: #0000FF; ">void</span><span style="color: #000000; ">{
</span><span style="color: #008080; ">2</span> <span style="color: #000000; ">    var row:Object;
</span><span style="color: #008080; ">3</span> <span style="color: #000000; ">    </span><span style="color: #0000FF; ">for</span><span style="color: #000000; "> each (row </span><span style="color: #0000FF; ">in</span><span style="color: #000000; "> </span><span style="color: #0000FF; ">event</span><span style="color: #000000; ">.result.FLIGHT_LIST){
</span><span style="color: #008080; ">4</span> <span style="color: #000000; ">        trace(row.AIRLINE </span><span style="color: #000000; ">+</span><span style="color: #000000; "> </span><span style="color: #000000; ">&quot;</span><span style="color: #000000; "> </span><span style="color: #000000; ">&quot;</span><span style="color: #000000; "> </span><span style="color: #000000; ">+</span><span style="color: #000000; "> row.CITYFROM);
</span><span style="color: #008080; ">5</span> <span style="color: #000000; ">    }
</span><span style="color: #008080; ">6</span> <span style="color: #000000; ">}</span></div>
</pre>
</div>
<p><strong>Line by Line</strong></p>
<ol>
<li>Function, again.</li>
<li>Use a place holder dynamic object</li>
<li>Loop at the table called FLIGHT_LIST ( looks like ABAP doesn&#8217;t it? )</li>
<li>Print to the console the fields you want ( looks like ABAP doesn&#8217;t it? )</li>
</ol>
<p>Disclaimer: There are a number of ways to call WebServices in Flex, I believe this is the most complete and &#8220;standard&#8221; way to call them, if not someone please point me to Adobe docs that show the most correct way.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.danmcweeney.com/57/feed</wfw:commentRss>
		<slash:comments>18</slash:comments>
		</item>
		<item>
		<title>Banana Cream Bribe</title>
		<link>http://blog.danmcweeney.com/55</link>
		<comments>http://blog.danmcweeney.com/55#comments</comments>
		<pubDate>Fri, 26 Oct 2007 20:50:03 +0000</pubDate>
		<dc:creator>dan</dc:creator>
				<category><![CDATA[et alii]]></category>
		<category><![CDATA[Flex]]></category>

		<guid isPermaLink="false">http://blog.danmcweeney.com/55</guid>
		<description><![CDATA[I guess if you want a bug fixed in the Flex SDK the best thing to do is send a Banana Cream Pie.&#160; If you open the About Flex Builder 3 and wait till the end you see the special thanks section: Looks pretty normal till you wait for the last line to scroll by: [...]]]></description>
			<content:encoded><![CDATA[<p>I guess if you want a bug fixed in the Flex SDK the best thing to do is send a Banana Cream Pie.&nbsp; If you open the About Flex Builder 3 and wait till the end you see the special thanks section:</p>
<p><a href="http://blog.danmcweeney.com/wp-content/uploads/2007/10/special-thanks.png" atomicselection="true"><img style="border-top-width: 0px; border-left-width: 0px; border-bottom-width: 0px; border-right-width: 0px" height="220" alt="special_thanks" src="http://blog.danmcweeney.com/wp-content/uploads/2007/10/special-thanks.png" width="472" border="0"></a></p>
<p>Looks pretty normal till you wait for the last line to scroll by:</p>
<p><a href="http://blog.danmcweeney.com/wp-content/uploads/2007/10/cream-pie.png" atomicselection="true"><img style="border-top-width: 0px; border-left-width: 0px; border-bottom-width: 0px; border-right-width: 0px" height="220" alt="Cream_Pie" src="http://blog.danmcweeney.com/wp-content/uploads/2007/10/cream-pie-thumb.png" width="472" border="0"></a></p>
<p>Don&#8217;t know what the deal is with Zuckerman&#8217;s Mom but, hey if you need that bug fixed in the SDK just send a pie over.</p>
<p><strong><u>UPDATE 11/02:</u></strong></p>
<p>Deepa&nbsp;Subramaniam from the Flex SDK team was kind enough to shed some light on this for me:</p>
<blockquote><p>Banana Cream Pie is a favorite treat of the FlexBuilder folks. Us SDK&#8217;ers are more partial to Peanut Brittle&#8230;.<br />sugar = our friend. </p>
</blockquote>
<p>So it turns out if you have a Flex Builder issue, Banana Cream Pie, if it&#8217;s a SDK problem Peanut Brittle c/o Deepa.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.danmcweeney.com/55/feed</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Majority Desk Architecture</title>
		<link>http://blog.danmcweeney.com/48</link>
		<comments>http://blog.danmcweeney.com/48#comments</comments>
		<pubDate>Tue, 09 Oct 2007 15:32:26 +0000</pubDate>
		<dc:creator>dan</dc:creator>
				<category><![CDATA[Flex]]></category>
		<category><![CDATA[innovation]]></category>
		<category><![CDATA[SAP]]></category>
		<category><![CDATA[SDN blogger]]></category>

		<guid isPermaLink="false">http://blog.danmcweeney.com/48</guid>
		<description><![CDATA[One of the common questions I was asked after demoing Majority Desk&#160;was how the heck is it built?&#160; To explain, I will first break down the individual components and then talk about how the Wiihands move across the screen.&#160; There is a lot more to the interactions in this system but, moving the Wiihands should [...]]]></description>
			<content:encoded><![CDATA[<p>One of the common questions I was asked after demoing <a href="http://www.majoritydesk.com" target="_blank">Majority Desk</a>&nbsp;was how the heck is it built?&nbsp; To explain, I will first break down the individual components and then talk about how the Wiihands move across the screen.&nbsp; There is a lot more to the interactions in this system but, moving the Wiihands should give you a pretty good insight into how the whole thing is built.&nbsp; Just to frame the following discussion Majority Desk is <em>mostly</em> an AIR application built using Flex Builder 3.</p>
<h3>ODE2Paper</h3>
<p>ODE2Paper is the main visualization and physics library I wrote that underpins the Majority Desk application.&nbsp; It binds the&nbsp;<a href="http://www.ode.org/" target="_blank">Open Dynamics Engine</a> (ODE for short), which is the underlying physics system to <a href="http://blog.papervision3d.org/" target="_blank">Papervision3d</a>&nbsp;(PV3D for short), the 3d rendering system.&nbsp; The foundation of this interaction is actually very simple: every time Flex fires an ENTER_FRAME event I issue a refresh command over a socket that is connected to the physics server.&nbsp; The physics server is a python application that uses <a href="http://pyode.sourceforge.net/" target="_blank">pyODE</a>&nbsp;to wrap the ODE libraries.&nbsp; The physics server &#8220;parses&#8221; the refresh command,</p>
<div class="wlWriterSmartContent" id="57F11A72-B0E5-49c7-9094-E3A15BD5B5E6:847a1a26-6409-4f1e-bde1-a076d040c00a" contenteditable="false" style="padding-right: 0px; display: inline; padding-left: 0px; float: none; padding-bottom: 0px; margin: 0px; width: 440px; padding-top: 0px">
<pre style="background-color:White;">
<div><!--

Code highlighting produced by Actipro CodeHighlighter (freeware)

http://www.CodeHighlighter.com/

--><span style="color: #0000FF; ">&lt;</span><span style="color: #800000; ">refresh</span><span style="color: #0000FF; ">/&gt;</span><span style="color: #000000; ">

</span></div>
</pre>
</div>
<p> iterates across all the objects in its world producing a new XML document with the position and transformation matrices of all the existing objects and sends that XML back to Flex.&nbsp; </p>
<div class="wlWriterSmartContent" id="57F11A72-B0E5-49c7-9094-E3A15BD5B5E6:1a99593d-90f2-4859-b6de-16affdb7deac" contenteditable="false" style="padding-right: 0px; display: inline; padding-left: 0px; float: none; padding-bottom: 0px; margin: 0px; width: 402px; padding-top: 0px">
<pre style="background-color:White;white-space:-moz-pre-wrap; white-space: -pre-wrap; white-space: -o-pre-wrap; white-space: pre-wrap; word-wrap: break-word;">
<div><!--

Code highlighting produced by Actipro CodeHighlighter (freeware)

http://www.CodeHighlighter.com/

--><span style="color: #0000FF; ">&lt;</span><span style="color: #800000; ">world</span><span style="color: #0000FF; ">&gt;</span><span style="color: #000000; ">
    </span><span style="color: #0000FF; ">&lt;</span><span style="color: #800000; ">o1 </span><span style="color: #FF0000; ">x</span><span style="color: #0000FF; ">=&quot;0.0&quot;</span><span style="color: #FF0000; "> y </span><span style="color: #0000FF; ">=&quot;0.0&quot;</span><span style="color: #FF0000; "> z</span><span style="color: #0000FF; ">=&quot;0.0&quot;</span><span style="color: #FF0000; "> r0</span><span style="color: #0000FF; ">=&quot;0.0&quot;</span><span style="color: #FF0000; "> r1</span><span style="color: #0000FF; ">=&quot;0.0&quot;</span><span style="color: #FF0000; "> r2</span><span style="color: #0000FF; ">=&quot;0.0&quot;</span><span style="color: #FF0000; "> r3</span><span style="color: #0000FF; ">=&quot;0.0&quot;</span><span style="color: #FF0000; "> r4</span><span style="color: #0000FF; ">=&quot;0.0&quot;</span><span style="color: #FF0000; "> r5</span><span style="color: #0000FF; ">=&quot;0.0&quot;</span><span style="color: #FF0000; "> r6</span><span style="color: #0000FF; ">=&quot;0.0&quot;</span><span style="color: #FF0000; "> r7</span><span style="color: #0000FF; ">=&quot;0.0&quot;</span><span style="color: #FF0000; "> r8</span><span style="color: #0000FF; ">=&quot;0.0&quot;</span><span style="color: #0000FF; ">/&gt;</span><span style="color: #000000; ">
    </span><span style="color: #0000FF; ">&lt;</span><span style="color: #800000; ">o2 </span><span style="color: #FF0000; ">x</span><span style="color: #0000FF; ">=&quot;10.0&quot;</span><span style="color: #FF0000; "> y </span><span style="color: #0000FF; ">=&quot;15.0&quot;</span><span style="color: #FF0000; "> z</span><span style="color: #0000FF; ">=&quot;10.0&quot;</span><span style="color: #FF0000; "> r0</span><span style="color: #0000FF; ">=&quot;0.0&quot;</span><span style="color: #FF0000; "> r1</span><span style="color: #0000FF; ">=&quot;0.0&quot;</span><span style="color: #FF0000; "> r2</span><span style="color: #0000FF; ">=&quot;0.0&quot;</span><span style="color: #FF0000; "> r3</span><span style="color: #0000FF; ">=&quot;0.0&quot;</span><span style="color: #FF0000; "> r4</span><span style="color: #0000FF; ">=&quot;0.0&quot;</span><span style="color: #FF0000; "> r5</span><span style="color: #0000FF; ">=&quot;0.0&quot;</span><span style="color: #FF0000; "> r6</span><span style="color: #0000FF; ">=&quot;0.0&quot;</span><span style="color: #FF0000; "> r7</span><span style="color: #0000FF; ">=&quot;0.0&quot;</span><span style="color: #FF0000; "> r8</span><span style="color: #0000FF; ">=&quot;0.0&quot;</span><span style="color: #0000FF; ">/&gt;</span><span style="color: #000000; ">
</span><span style="color: #0000FF; ">&lt;</span><span style="color: #800000; ">collisions</span><span style="color: #0000FF; ">/&gt;</span><span style="color: #000000; ">
</span><span style="color: #0000FF; ">&lt;/</span><span style="color: #800000; ">world</span><span style="color: #0000FF; ">&gt;</span><span style="color: #000000; ">

</span></div>
</pre>
</div>
<p>When this data transfer is complete on the Flex side, I move all the objects in the PV3d scene and then call the camera render.&nbsp; Simple right? <img src='http://blog.danmcweeney.com/wp-includes/images/smilies/icon_smile.gif' alt=':-)' class='wp-smiley' /> </p>
<h3>A Wii bit of background</h3>
<p>The Wiimote is a blue tooth transmitter, it reports its position and state to the blue tooth receiver on the client computer.&nbsp; It determines its position by &#8220;looking&#8221; through the IR port on the front of the Wiimote at the poorly named sensor bar.&nbsp; The sensor bar in reality has no sensors in it &#8212; it has two IR emitters that allow the Wiimote to triangulate its X and Y position in space.&nbsp; The Wiimote also has an accelerometer on board that allows it to measure movement in the X, Y, Z planes (pitch, yaw, and roll).&nbsp; This page has a mountain of <a href="http://www.wiili.org/index.php/Wiimote" target="_blank">technical detail about the Wiimote</a>.</p>
<h3>WiiFlash</h3>
<p>The information from the Wiimote is sent to the <a href="http://www.wiiflash.org" target="_blank">WiiFlash</a>&nbsp;server.&nbsp; WiiFlash removes all the complexity out of using Wiimotes to control any Flash application.&nbsp; The API is pretty complete and we found it to be fairly stable.&nbsp; This is the section <a href="http://blog.ewherrmann.com/" target="_blank">Eddie</a> dealt with most so, I can&#8217;t talk too intelligently about it except to say that we use the WiiFlash AS3 API to access all the position and button state information from the Wiimote.&nbsp; The API handles all the calls&nbsp;through a local connection that streams the information from the projects <a href="http://code.google.com/p/wiiflash/downloads/list" target="_blank">WiiFlash Server</a>, which for now only runs on windows, sorry Mac faithful.&nbsp; </p>
<p>This pretty much rounds out the subsystems that lie underneath the application.&nbsp; This doesn&#8217;t really explain how the thing works so, I will walk you through how the Wiihands move around the screen to hopefully give you a better idea of what is going on.</p>
<h3>Moving Wiihands</h3>
<p>The most common thing we do in Majority Desk&nbsp;is move our Wiihands to interact with the world.&nbsp; To allow interactions with the state of the physical world maintained by the physics server we have a set of commands in ODE2Paper.&nbsp; The ones that matter for the Wiihands are createSphere, setObjPos, createJoint and breakJoint.&nbsp; These methods serve as proxy for the real commands flying over to the physics server.&nbsp; The rationale for this is again the main underlying concept that the physics server knows where the objects are and PV3d simply renders them.&nbsp; So all the interactions are really taking place on the physics server.&nbsp; The Wiihands are represented in the physics system as sphere because they are in reality just a cool texture wrapped on a sphere in PV3d.</p>
<p>So as a Wiimote moves we get its position and call a setObjPos method in ODE2Paper library which moves the object in the physics server.&nbsp; Again the physics server leads and PV3d simply renders a view of the world.</p>
<h3>Grabbing stuff</h3>
<p>If you got the chance during Hacker Night or our Meet the Jammers session to mess with Majority Desk you may remember that if you hold the trigger and bump into something&nbsp;with your Wiihands you can grab it.&nbsp; Letting go of the trigger will release the object and let it float around again.&nbsp; This is achieved using the collisions&nbsp;XML node that I didn&#8217;t talk about earlier.&nbsp; If you look back at the XML doc that the physics server creates to represent the world you will see an empty node there for collisions.&nbsp; ODE2Paper notifies our Flex application that two bodies are about to collide via this XML node.&nbsp; This allows us to detect that the Wiihand is touching something and then build a joint, using the ODE2Paper method createJoint.&nbsp; A joint is a type of attachment between two bodies in ODE, we use simple static joints but a whole slew of <a href="http://www.ode.org/ode-latest-userguide.html#sec_7_3_0" target="_blank">different joints types are supported by ODE</a>.&nbsp; This is why the widget seems to follow a Wiihand around as it moves.&nbsp; The great thing is this affect is achieved by just calling setObjPos on the&nbsp;Wiihand, which is the normal behavior described previously.&nbsp;&nbsp; To release the object we simply call breakJoint and the physics server breaks the joint allow the attached object to move fluidly again.</p>
<p>If you want a run down of links and a good video that shows <a href="http://www.youtube.com/watch?v=jaYmXLIPVSc" target="_blank">Majority Desk in action</a>, check out <a href="http://blog.ewherrmann.com/2007/10/08/majority-desk-get-your-wiihands-on/" target="_blank">Eddie&#8217;s blog post about it</a>.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.danmcweeney.com/48/feed</wfw:commentRss>
		<slash:comments>10</slash:comments>
		</item>
		<item>
		<title>TechEd US 2007</title>
		<link>http://blog.danmcweeney.com/45</link>
		<comments>http://blog.danmcweeney.com/45#comments</comments>
		<pubDate>Thu, 04 Oct 2007 17:53:56 +0000</pubDate>
		<dc:creator>dan</dc:creator>
				<category><![CDATA[Flex]]></category>
		<category><![CDATA[innovation]]></category>
		<category><![CDATA[SAP]]></category>
		<category><![CDATA[SDN blogger]]></category>
		<category><![CDATA[UI]]></category>

		<guid isPermaLink="false">http://blog.danmcweeney.com/45</guid>
		<description><![CDATA[So far the highlight of TechEd for me has been people&#8217;s reaction to Majority Desk.&#160; I said to&#160;a number of people before the demo that everyone&#8217;s reactions would be the same, &#8220;Oh my god&#8230;&#8221;&#160; The problem is that that reaction would come because of two very different reasons, &#8220;Oh my god&#8230; what is wrong with [...]]]></description>
			<content:encoded><![CDATA[<p>So far the highlight of TechEd for me has been people&#8217;s reaction to <a href="http://www.majoritydesk.com" target="_blank">Majority Desk</a>.&nbsp; I said to&nbsp;a number of people before the demo that everyone&#8217;s reactions would be the same, &#8220;Oh my god&#8230;&#8221;&nbsp; The problem is that that reaction would come because of two very different reasons, &#8220;Oh my god&#8230; what is wrong with you people that has no business value!&#8221; or &#8220;Oh my god&#8230; that is the coolest thing I&#8217;ve seen in a long time.&#8221;&nbsp; </p>
<p>It seems that most people fall in the latter category.&nbsp; I&#8217;ve already spoke to a number SDNers from all different industries who see how they can use this type of interface in a broad range of applications.&nbsp; A airplane manufacturer navigating large engineering drawings to business people visualizing data sets in 3d to see patterns.&nbsp; This was the reaction we were hoping to create in the community a true sense of innovation and possibility.&nbsp; It&#8217;s also been a blast watching people mess around with the interface.</p>
<p>Here are some great photos from hacker night with Mark Finnern and Marilyn Pratt messing around with Majority Desk.</p>
<p><a title="Photo Sharing" href="http://www.zooomr.com/photos/danmcweeney/3430359/"><img height="333" alt="IMG_1673" src="http://static.zooomr.com/images/3430359_904aa39586.jpg" width="445"></a></p>
<p><a title="Photo Sharing" href="http://www.zooomr.com/photos/danmcweeney/3430334/"><img height="500" alt="IMG_1682" src="http://static.zooomr.com/images/3430334_0d806761ed.jpg" width="375"></a></p>
]]></content:encoded>
			<wfw:commentRss>http://blog.danmcweeney.com/45/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Majority Desk Sneak Peek</title>
		<link>http://blog.danmcweeney.com/44</link>
		<comments>http://blog.danmcweeney.com/44#comments</comments>
		<pubDate>Wed, 03 Oct 2007 23:28:25 +0000</pubDate>
		<dc:creator>dan</dc:creator>
				<category><![CDATA[Flex]]></category>
		<category><![CDATA[innovation]]></category>
		<category><![CDATA[SAP]]></category>
		<category><![CDATA[SDN blogger]]></category>

		<guid isPermaLink="false">http://blog.danmcweeney.com/44</guid>
		<description><![CDATA[Before the Demo Jam got started we gave James and CotÃ© from RedMonk a sneak peek of our demo called Majority Desk.&#160; Majority Desk is a 3d virtual environment that allows you to interact with Flex based widgets with the help of a pair of Wiimotes.&#160;&#160; CotÃ© talks a bit about Majority Desk but, a [...]]]></description>
			<content:encoded><![CDATA[<p>Before the Demo Jam got started we gave <a href="http://www.redmonk.com/jgovernor/" target="_blank">James</a> and <a href="http://www.redmonk.com/cote/" target="_blank">CotÃ©</a> from <a href="http://www.redmonk.com" target="_blank">RedMonk</a> a sneak peek of our demo called <a href="http://www.majoritydesk.com" target="_blank">Majority Desk</a>.&nbsp; Majority Desk is a 3d virtual environment that allows you to interact with Flex based widgets with the help of a pair of Wiimotes.&nbsp;&nbsp; <a href="http://www.redmonk.com/cote/2007/10/03/majority-desk-wiimote-3d-widget-desktop-totally-sick/" target="_blank">CotÃ© talks a bit about Majority Desk</a> but, a video is worth 1,000 words * 32 * (length of video).</p>
<p> <script src="http://www.podtech.net/player/popup.js" type="text/javascript"></script> <embed src="http://www.podtech.net/player/podtech-player.swf?bc=c90ad26ba7b74e3b80c9fcf4ad1158c0" width="320" height="269" type="application/x-shockwave-flash" allowscriptaccess="always" flashvars="content=http://media1.podtech.net/media/2007/10/PID_012730/Podtech_MajorityDesk_Wiimote_widget_d.flv&amp;totalTime=277000&amp;permalink=http://www.podtech.net/home/4299/majority-desk-wiimote-3d-widget-desktop&amp;breadcrumb=c90ad26ba7b74e3b80c9fcf4ad1158c0"></p>
<p>Big thanks to CotÃ© at Redmonk for getting this video up so quickly!</p>
<p>For those of you at TechEd you can drop by the clubhouse at 5 to &#8220;get your Wiihands on&#8221; MajorityDesk.</p>
<p>Also we will be talking about the architecture and the OSS we used at this evening&#8217;s hacker night.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.danmcweeney.com/44/feed</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Flex / Twitter App Take 2</title>
		<link>http://blog.danmcweeney.com/29</link>
		<comments>http://blog.danmcweeney.com/29#comments</comments>
		<pubDate>Thu, 14 Jun 2007 18:44:08 +0000</pubDate>
		<dc:creator>dan</dc:creator>
				<category><![CDATA[Flex]]></category>
		<category><![CDATA[UI]]></category>

		<guid isPermaLink="false">http://blog.danmcweeney.com/29</guid>
		<description><![CDATA[If you think this looks like any fun and don&#8217;t know anything about WPF go check out Kurt Brockett&#8217;s blog for an interesting challenge. Thanks to a great tip from Matt Chotin, from Adobe, in the comments of my previous post I take a massive step forward in the UI department.&#160; Again, the Open Source [...]]]></description>
			<content:encoded><![CDATA[<p>If you think this looks like any fun and don&#8217;t know anything about WPF go check out <a href="http://www.brockett.net/?p=187">Kurt Brockett&#8217;s blog</a> for an interesting challenge.</p>
<p>Thanks to a great tip from <a href="http://weblogs.macromedia.com/mchotin" target="_blank">Matt Chotin</a>, from Adobe, in the <a href="http://blog.danmcweeney.com/28#comment-2223">comments of my previous post</a> I take a massive step forward in the UI department.&nbsp; Again, the Open Source gods ( is this open source? ) work their magic to give me an even more useful component:&nbsp; <a href="http://mark-shepherd.com/blog/2006/11/17/a-flex-component-for-graph-visualization/" target="_blank">SpringGraph</a>&nbsp;from another Adobe Engineer ( seeing a pattern are we ) named <a href="http://mark-shepherd.com/" target="_blank">Mark Shepard</a>.&nbsp; He hasn&#8217;t blogged in some time, so I&#8217;m not sure he is still doing stuff with Adobe/Flex or blogging but, his component totally rules and fits my needs pretty closely.&nbsp; Here is the original <a href="http://mark-shepherd.com/SpringGraph/AmazonDemo/bin/AmazonDemo.html" target="_blank">SpringGraph Demo</a>&nbsp;and the <a href="http://mark-shepherd.com/SpringGraph/RoamerDemo/bin/RoamerDemo.html" target="_blank">Roamer Demo</a> which is like the SpringGraph just with nodes hidden or collapsed ( which may be the final component I use ).&nbsp; Well onto, what I&#8217;m trying to do:</p>
<h3>Shiny New Object</h3>
<p>First things first, time to see what makes the SpringGraph tick.&nbsp; Given my limited knowledge of all things Flash, I had to piece together how the main body of his MXML file even worked.&nbsp; </p>
</p>
<div class="wlWriterSmartContent" id="57F11A72-B0E5-49c7-9094-E3A15BD5B5E6:f2860ffb-4598-48ef-b718-7d79559e5abc" contenteditable="false" style="padding-right: 0px; display: inline; padding-left: 0px; float: none; padding-bottom: 0px; margin: 0px; padding-top: 0px">
<pre style="background-color:White;">
<div><!--

Code highlighting produced by Actipro CodeHighlighter (freeware)

http://www.CodeHighlighter.com/

--><span style="color: #0000FF; ">&lt;</span><span style="color: #800000; ">fc:SpringGraph </span><span style="color: #FF0000; ">id</span><span style="color: #0000FF; ">=&quot;s&quot;</span><span style="color: #FF0000; "> backgroundColor</span><span style="color: #0000FF; ">=&quot;#ffffff&quot;</span><span style="color: #FF0000; ">
    lineColor</span><span style="color: #0000FF; ">=&quot;#333388&quot;</span><span style="color: #FF0000; "> left</span><span style="color: #0000FF; ">=&quot;0&quot;</span><span style="color: #FF0000; "> right</span><span style="color: #0000FF; ">=&quot;0&quot;</span><span style="color: #FF0000; "> top</span><span style="color: #0000FF; ">=&quot;0&quot;</span><span style="color: #FF0000; ">
                    bottom</span><span style="color: #0000FF; ">=&quot;0&quot;</span><span style="color: #FF0000; ">
                    itemRenderer</span><span style="color: #0000FF; ">=&quot;AmazonItemView&quot;</span><span style="color: #FF0000; ">
                    repulsionFactor</span><span style="color: #0000FF; ">=&quot;{rep.value}&quot;</span><span style="color: #FF0000; ">
    </span><span style="color: #0000FF; ">&gt;</span><span style="color: #000000; ">
</span><span style="color: #0000FF; ">&lt;/</span><span style="color: #800000; ">fc:SpringGraph</span><span style="color: #0000FF; ">&gt;</span></div>
</pre>
</div>
<p>It took me a few minutes to understand the beauty of the itemRenderer system built into Flex.&nbsp; If you check out the other source objects in Mark&#8217;s project you will notice AmazonItem.as and AmazonItemView.as.&nbsp; Think of this as a mini MVC subsystem.&nbsp; With a collection of AmazonItem-s being the model, the SpringGraph control being the controller and the AmazonItemView obviously being the view.&nbsp;&nbsp; This is made clearer when you add the following AS3 snippet to the mix</p>
</p>
<div class="wlWriterSmartContent" id="57F11A72-B0E5-49c7-9094-E3A15BD5B5E6:ab9f536d-8534-42df-b63d-218d9bcdc4d0" contenteditable="false" style="padding-right: 0px; display: inline; padding-left: 0px; float: none; padding-bottom: 0px; margin: 0px; width: 478px; padding-top: 0px">
<pre style="background-color:White;">
<div><!--

Code highlighting produced by Actipro CodeHighlighter (freeware)

http://www.CodeHighlighter.com/

--><span style="color: #0000FF; ">private</span><span style="color: #000000; "> var items: Graph;
</span><span style="color: #0000FF; ">public</span><span style="color: #000000; "> function addItem(id: String, name: String,
               linkTo: AmazonItem): AmazonItem {
    var newItem: AmazonItem </span><span style="color: #000000; ">=</span><span style="color: #000000; ">
               </span><span style="color: #0000FF; ">new</span><span style="color: #000000; "> AmazonItem(id, name);
    items.add(newItem);
    </span><span style="color: #0000FF; ">if</span><span style="color: #000000; ">(linkTo </span><span style="color: #000000; ">!=</span><span style="color: #000000; "> </span><span style="color: #0000FF; ">null</span><span style="color: #000000; ">)
        items.link(newItem, linkTo);
    s.dataProvider </span><span style="color: #000000; ">=</span><span style="color: #000000; "> items;
    </span><span style="color: #0000FF; ">return</span><span style="color: #000000; "> newItem;
}</span></div>
</pre>
</div>
<p>What is happening here?&nbsp; Well as you call the addItem function an instance of the model, AmazonItem is created and added to collection.&nbsp; This collection is then bound to the dataProvider of the SpringGraph.&nbsp; When SpringGraph is drawn on the stage it loops at this dataProvider and instantiates a view object named itemRenderer for each item in the dataProvider.&nbsp; So this allows you to completely change what the SpringGrid is rendering on your behalf &#8212; pretty cool, huh?</p>
<h3>My &#8220;Model&#8221;</h3>
<p>Now that I think I understand how that component works I need a place to store some data about a Twitter user.&nbsp; Normally, you could just create a basic class and use that but, in the case of this component it seems you need to subclass the delivered Item class.&nbsp; Once again, no big deal.&nbsp; Created a new class called TwitterPerson.&nbsp; That class has a few attributes:</p>
</p>
<div class="wlWriterSmartContent" id="57F11A72-B0E5-49c7-9094-E3A15BD5B5E6:355efea0-f088-4157-8f5d-d910d8276d5e" contenteditable="false" style="padding-right: 0px; display: inline; padding-left: 0px; float: none; padding-bottom: 0px; margin: 0px; padding-top: 0px">
<pre style="background-color:White;">
<div><!--

Code highlighting produced by Actipro CodeHighlighter (freeware)

http://www.CodeHighlighter.com/

--><span style="color: #0000FF; ">public</span><span style="color: #000000; "> </span><span style="color: #0000FF; ">class</span><span style="color: #000000; "> TwitterPerson extends Item
{
    [Bindable]</span><span style="color: #0000FF; ">public</span><span style="color: #000000; "> var screenName:String;
    [Bindable]</span><span style="color: #0000FF; ">public</span><span style="color: #000000; "> var name:String;
    [Bindable]</span><span style="color: #0000FF; ">public</span><span style="color: #000000; "> var profile_image:String;</span></div>
</pre>
</div>
<p>These will store the data returned from the API, I&#8217;ve named the attributes nearly the same as the API to make it easier to follow.&nbsp; The attributes are bindable so that as I fill in the information the &#8220;view&#8221; will update automatically.&nbsp; The constructor is uber-simple:</p>
</p>
<div class="wlWriterSmartContent" id="57F11A72-B0E5-49c7-9094-E3A15BD5B5E6:18822d05-8883-487b-a455-41a5b79435f2" contenteditable="false" style="padding-right: 0px; display: inline; padding-left: 0px; float: none; padding-bottom: 0px; margin: 0px; padding-top: 0px">
<pre style="background-color:White;">
<div><!--

Code highlighting produced by Actipro CodeHighlighter (freeware)

http://www.CodeHighlighter.com/

--><span style="color: #0000FF; ">public</span><span style="color: #000000; "> function TwitterPerson(xml:XML){
    screenName </span><span style="color: #000000; ">=</span><span style="color: #000000; "> xml.screen_name;
    name </span><span style="color: #000000; ">=</span><span style="color: #000000; "> xml.name;
    profile_image </span><span style="color: #000000; ">=</span><span style="color: #000000; "> xml.profile_image_url;
}</span></div>
</pre>
</div>
<p>To make it as easy as possible to construct the TwitterPerson I just pass in an XML node and map the parameters myself.&nbsp; If you check out the API you will see that the two services I use &#8220;statuses/friends/&#8221; and &nbsp;&#8221;users/show/&#8221; return different data but have the same information about each person with the same attribute names ( thanks for the consistency Twitter guys! ).</p>
<h3>My &#8220;View&#8221;</h3>
<p>The other piece I need to construct is the view that the SpringGraph will call to render the data stored in the model.&nbsp; For right now all I want to do is put the picture of the person being rendered up there and give a tool tip for their name.&nbsp; Flex makes something like this so easy it&#8217;s barely worth mentioning but for completeness:</p>
<div class="wlWriterSmartContent" id="57F11A72-B0E5-49c7-9094-E3A15BD5B5E6:d57cfa28-e656-4f16-8755-00cd16f0a2b8" contenteditable="false" style="padding-right: 0px; display: inline; padding-left: 0px; float: none; padding-bottom: 0px; margin: 0px; padding-top: 0px">
<pre style="background-color:White;">
<div><!--

Code highlighting produced by Actipro CodeHighlighter (freeware)

http://www.CodeHighlighter.com/

--><span style="color: #0000FF; ">&lt;</span><span style="color: #800000; ">mx:VBox </span><span style="color: #FF0000; ">xmlns:mx</span><span style="color: #0000FF; ">=&quot;http://www.adobe.com/2006/mxml&quot;</span><span style="color: #0000FF; ">&gt;</span><span style="color: #000000; ">
    </span><span style="color: #0000FF; ">&lt;</span><span style="color: #800000; ">mx:Image </span><span style="color: #FF0000; ">source</span><span style="color: #0000FF; ">=&quot;{data.profile_image}&quot;</span><span style="color: #FF0000; ">
        scaleX</span><span style="color: #0000FF; ">=&quot;1&quot;</span><span style="color: #FF0000; "> scaleY</span><span style="color: #0000FF; ">=&quot;1&quot;</span><span style="color: #FF0000; ">
        toolTip</span><span style="color: #0000FF; ">=&quot;{data.name}&quot;</span><span style="color: #0000FF; ">/&gt;</span><span style="color: #000000; ">
</span><span style="color: #0000FF; ">&lt;/</span><span style="color: #800000; ">mx:VBox</span><span style="color: #0000FF; ">&gt;</span><span style="color: #000000; ">
</span></div>
</pre>
</div>
<h3><font face="Verdana"></font></h3>
<h3>Two Heads are better then one but One&#8217;s a start</h3>
<p>Back in the main MXML of our application things have changed a bit:</p>
</p>
<div class="wlWriterSmartContent" id="57F11A72-B0E5-49c7-9094-E3A15BD5B5E6:17b0f049-a2e5-44c1-8915-a9dde70ca429" contenteditable="false" style="padding-right: 0px; display: inline; padding-left: 0px; float: none; padding-bottom: 0px; margin: 0px; padding-top: 0px">
<pre style="background-color:White;">
<div><!--

Code highlighting produced by Actipro CodeHighlighter (freeware)

http://www.CodeHighlighter.com/

--><span style="color: #0000FF; ">&lt;</span><span style="color: #800000; ">mx:HTTPService </span><span style="color: #FF0000; ">id</span><span style="color: #0000FF; ">=&quot;myInfoService&quot;</span><span style="color: #FF0000; ">
    url</span><span style="color: #0000FF; ">=&quot;http://twitter.com/users/show/dan_mcweeney.xml&quot;</span><span style="color: #FF0000; ">
    resultFormat</span><span style="color: #0000FF; ">=&quot;e4x&quot;</span><span style="color: #FF0000; ">
    result</span><span style="color: #0000FF; ">=&quot;onMyInfoServiceResult(event)&quot;</span><span style="color: #FF0000; ">
    fault</span><span style="color: #0000FF; ">=&quot;onMyInfoServiceFailed(event)&quot;</span><span style="color: #FF0000; ">
</span><span style="color: #0000FF; ">/&gt;</span><span style="color: #000000; ">

</span><span style="color: #0000FF; ">&lt;</span><span style="color: #800000; ">fc:SpringGraph </span><span style="color: #FF0000; ">id</span><span style="color: #0000FF; ">=&quot;springLayout&quot;</span><span style="color: #FF0000; ">
    backgroundColor</span><span style="color: #0000FF; ">=&quot;#ffffff&quot;</span><span style="color: #FF0000; "> lineColor</span><span style="color: #0000FF; ">=&quot;#333388&quot;</span><span style="color: #FF0000; "> left</span><span style="color: #0000FF; ">=&quot;0&quot;</span><span style="color: #FF0000; ">
    right</span><span style="color: #0000FF; ">=&quot;0&quot;</span><span style="color: #FF0000; "> top</span><span style="color: #0000FF; ">=&quot;0&quot;</span><span style="color: #FF0000; "> bottom</span><span style="color: #0000FF; ">=&quot;0&quot;</span><span style="color: #FF0000; ">
    itemRenderer</span><span style="color: #0000FF; ">=&quot;TwitterPersonView&quot;</span><span style="color: #FF0000; ">
    repulsionFactor</span><span style="color: #0000FF; ">=&quot;.80&quot;</span><span style="color: #FF0000; "> canDragNodes</span><span style="color: #0000FF; ">=&quot;false&quot;</span><span style="color: #FF0000; ">
</span><span style="color: #0000FF; ">/&gt;</span></div>
</pre>
</div>
<p>You can see how nice and clean the SpringGraph is to use it was basically a one for one swap of other component.&nbsp; Another change here is method used to fetch the data.&nbsp; As you will see in the next section I leave it up to the Model class itself to determine how their friends are, hopefully this will be a good decision architecturally, so the start of the application is to just call the send method of the myInfoService HTTPService.&nbsp; The result event is then triggered and that&#8217;s where everything gets stuck back together again.</p>
<p><p>At this point if you are following along, which I&#8217;m fairly certain no one is, you should get one head floating in the middle of a big white background, yay!&nbsp; Although the astute observer will notice that I snuck a new method into that last&nbsp;snippet of code: &#8220;person.getFriends()&#8221;.&nbsp;</p>
<p>&nbsp;<a href='http://blog.danmcweeney.com/wp-content/uploads/2007/06/onehead.PNG' title='One head'><img src='http://blog.danmcweeney.com/wp-content/uploads/2007/06/onehead.thumbnail.PNG' alt='One head' /></a></p>
<p>&nbsp;</p>
</p>
<h3><strike>Model^2</strike> Math.pow(Model,2)</h3>
<p>As I mentioned eariler I have now moved the getting of friends into the Model.&nbsp; I did this to hopefully make it easier for some ideas I have in the long run but also to see how to make a HTTPService entirely in AS.&nbsp; All this method does is ask the Twitter API to for the user&#8217;s list of friends:</p>
</p>
<div class="wlWriterSmartContent" id="57F11A72-B0E5-49c7-9094-E3A15BD5B5E6:d450f8e8-6182-4a8e-a895-f4a6d70eb251" contenteditable="false" style="padding-right: 0px; display: inline; padding-left: 0px; float: none; padding-bottom: 0px; margin: 0px; padding-top: 0px">
<pre style="background-color:White;">
<div><!--

Code highlighting produced by Actipro CodeHighlighter (freeware)

http://www.CodeHighlighter.com/

--><span style="color: #008080; "> 1</span> <span style="color: #0000FF; ">public</span><span style="color: #000000; "> function getFriends():</span><span style="color: #0000FF; ">void</span><span style="color: #000000; ">{
</span><span style="color: #008080; "> 2</span> <span style="color: #000000; ">    var friendsService:HTTPService </span><span style="color: #000000; ">=</span><span style="color: #000000; "> </span><span style="color: #0000FF; ">new</span><span style="color: #000000; "> HTTPService();
</span><span style="color: #008080; "> 3</span> <span style="color: #000000; ">    var friends:Array </span><span style="color: #000000; ">=</span><span style="color: #000000; "> </span><span style="color: #0000FF; ">new</span><span style="color: #000000; "> Array();
</span><span style="color: #008080; "> 4</span> <span style="color: #000000; ">    friendsService.url </span><span style="color: #000000; ">=</span><span style="color: #000000; ">
</span><span style="color: #008080; "> 5</span> <span style="color: #000000; ">       </span><span style="color: #000000; ">&quot;</span><span style="color: #000000; ">http://twitter.com/statuses/friends/</span><span style="color: #000000; ">&quot;</span><span style="color: #000000; ">  </span><span style="color: #000000; ">+</span><span style="color: #000000; ">
</span><span style="color: #008080; "> 6</span> <span style="color: #000000; ">       screenName </span><span style="color: #000000; ">+</span><span style="color: #000000; "> </span><span style="color: #000000; ">&quot;</span><span style="color: #000000; ">.xml</span><span style="color: #000000; ">&quot;</span><span style="color: #000000; ">;
</span><span style="color: #008080; "> 7</span> <span style="color: #000000; ">    friendsService.resultFormat </span><span style="color: #000000; ">=</span><span style="color: #000000; "> </span><span style="color: #000000; ">&quot;</span><span style="color: #000000; ">e4x</span><span style="color: #000000; ">&quot;</span><span style="color: #000000; ">;
</span><span style="color: #008080; "> 8</span> <span style="color: #000000; ">    friendsService.addEventListener(FaultEvent.FAULT,
</span><span style="color: #008080; "> 9</span> <span style="color: #000000; ">        friendsFault);
</span><span style="color: #008080; ">10</span> <span style="color: #000000; ">    friendsService.addEventListener(</span><span style="color: #000000; ">&quot;</span><span style="color: #000000; ">result</span><span style="color: #000000; ">&quot;</span><span style="color: #000000; ">,
</span><span style="color: #008080; ">11</span> <span style="color: #000000; ">        friendsResult);
</span><span style="color: #008080; ">12</span> <span style="color: #000000; ">    friendsService.send();
</span><span style="color: #008080; ">13</span> <span style="color: #000000; ">}</span></div>
</pre>
</div>
<p>The only remaining mystery is what happens in the friendsResult method which gets bound to the &#8220;result&#8221; event on line 10-11.&nbsp; </p>
<div class="wlWriterSmartContent" id="57F11A72-B0E5-49c7-9094-E3A15BD5B5E6:f5ffe17f-bbbc-4b34-b090-bebc395f0b64" contenteditable="false" style="padding-right: 0px; display: inline; padding-left: 0px; float: none; padding-bottom: 0px; margin: 0px; padding-top: 0px">
<pre style="background-color:White;">
<div><!--

Code highlighting produced by Actipro CodeHighlighter (freeware)

http://www.CodeHighlighter.com/

--><span style="color: #0000FF; ">private</span><span style="color: #000000; "> function friendsResult(result:ResultEvent):</span><span style="color: #0000FF; ">void</span><span style="color: #000000; ">{
    var friendsArray:Array </span><span style="color: #000000; ">=</span><span style="color: #000000; "> </span><span style="color: #0000FF; ">new</span><span style="color: #000000; "> Array();
    </span><span style="color: #0000FF; ">for</span><span style="color: #000000; "> each (var userEntry:XML </span><span style="color: #0000FF; ">in</span><span style="color: #000000; "> result.result.user){
        friendsArray.push(</span><span style="color: #0000FF; ">new</span><span style="color: #000000; "> TwitterPerson(userEntry));
    }
    sevenDegress_2(Application.application).
          onAddFriends(</span><span style="color: #0000FF; ">this</span><span style="color: #000000; ">, friendsArray);
}</span></div>
</pre>
</div>
<p>When the friends HTTPService returns it has a list of all the user&#8217;s friends and their current status.&nbsp; The method just pushes these newly minted TwitterPerson(s) into an array and then calls another mysterious method from the application that contains it.&nbsp; I don&#8217;t know if this is the best way to do this or not &#8212; seems like a bad case of statically linking these two objects but it seemed like the easiest way at the time.&nbsp; This line of code gets the root Application object&#8217;s attribute called application and invokes a method on it.&nbsp; For this to work at compile time though you need to cast that application attribute over to to the specific type of your application hence that funky, sevenDegrees_2&nbsp;thing you see there.&nbsp; The source code to that one extra method is also pretty straightforward thanks once again to Mark&#8217;s Graph class:</p>
<div class="wlWriterSmartContent" id="57F11A72-B0E5-49c7-9094-E3A15BD5B5E6:31c7b480-2259-4d26-af28-cdb0b42dc5c0" contenteditable="false" style="padding-right: 0px; display: inline; padding-left: 0px; float: none; padding-bottom: 0px; margin: 0px; padding-top: 0px">
<pre style="background-color:White;">
<div><!--

Code highlighting produced by Actipro CodeHighlighter (freeware)

http://www.CodeHighlighter.com/

--><span style="color: #0000FF; ">public</span><span style="color: #000000; "> function onAddFriends(node:TwitterPerson,
        friendsList:Array):</span><span style="color: #0000FF; ">void</span><span style="color: #000000; ">{
    </span><span style="color: #0000FF; ">for</span><span style="color: #000000; "> each (var person:TwitterPerson </span><span style="color: #0000FF; ">in</span><span style="color: #000000; "> friendsList){
        people.add(person);
        people.link(person, node);
    }
}</span></div>
</pre>
</div>
<p><strong><font face="Trebuchet MS"></font></strong></p>
<p>When the friends HTTPService gets a result it passes it back up to the application which in turn modifies the data provider by adding the new nodes ( via the add() method ) and then linking them to each other ( via the link() method ).&nbsp; This should now produce the pretty little Poof ball like below:</p>
<p><a href='http://blog.danmcweeney.com/wp-content/uploads/2007/06/poof.PNG' title='Poof'><img src='http://blog.danmcweeney.com/wp-content/uploads/2007/06/poof.thumbnail.PNG' alt='Poof' /></a></p>
<p>&nbsp;</p>
<h3>Hatchet Attack</h3>
<p>This control is actually a little <em>too</em> useful for my needs, I don&#8217;t really want anyone to be able to drag folks around once they have been placed on the screen so, I have to delve into Mark&#8217;s control and get rid of that functionality.&nbsp; This turned out to be a fairly straightforward:</p>
</p>
<div class="wlWriterSmartContent" id="57F11A72-B0E5-49c7-9094-E3A15BD5B5E6:11683dd4-f095-41f9-a55b-c5318350d4c0" contenteditable="false" style="padding-right: 0px; display: inline; padding-left: 0px; float: none; padding-bottom: 0px; margin: 0px; width: 531px; padding-top: 0px">
<pre style="background-color:White;">
<div><!--

Code highlighting produced by Actipro CodeHighlighter (freeware)

http://www.CodeHighlighter.com/

--><span style="color: #008080; "> 1</span> <span style="color: #0000FF; ">private</span><span style="color: #000000; "> function mouseDownEvent
</span><span style="color: #008080; "> 2</span> <span style="color: #000000; ">       (</span><span style="color: #0000FF; ">event</span><span style="color: #000000; ">: MouseEvent):</span><span style="color: #0000FF; ">void</span><span style="color: #000000; ">  {
</span><span style="color: #008080; "> 3</span> <span style="color: #000000; ">    var now: </span><span style="color: #0000FF; ">int</span><span style="color: #000000; "> </span><span style="color: #000000; ">=</span><span style="color: #000000; "> getTimer();
</span><span style="color: #008080; "> 4</span> <span style="color: #000000; ">    </span><span style="color: #0000FF; ">if</span><span style="color: #000000; ">((now </span><span style="color: #000000; ">-</span><span style="color: #000000; "> lastMouseDownTime) </span><span style="color: #000000; ">&lt;</span><span style="color: #000000; "> </span><span style="color: #000000; ">300</span><span style="color: #000000; ">) {
</span><span style="color: #008080; "> 5</span> <span style="color: #000000; ">        </span><span style="color: #008000; ">//</span><span style="color: #008000; "> it's a double-click</span><span style="color: #008000; ">
</span><span style="color: #008080; "> 6</span> <span style="color: #008000; "></span><span style="color: #000000; ">        var node: GraphNode </span><span style="color: #000000; ">=</span><span style="color: #000000; "> _dataProvider.findNode(
</span><span style="color: #008080; "> 7</span> <span style="color: #000000; ">                UIComponent(</span><span style="color: #0000FF; ">event</span><span style="color: #000000; ">.currentTarget));
</span><span style="color: #008080; "> 8</span> <span style="color: #000000; ">        </span><span style="color: #0000FF; ">if</span><span style="color: #000000; ">(node </span><span style="color: #000000; ">!=</span><span style="color: #000000; "> </span><span style="color: #0000FF; ">null</span><span style="color: #000000; ">) {
</span><span style="color: #008080; "> 9</span> <span style="color: #000000; ">            dragEnd(</span><span style="color: #0000FF; ">event</span><span style="color: #000000; ">);
</span><span style="color: #008080; ">10</span> <span style="color: #000000; ">            </span><span style="color: #0000FF; ">if</span><span style="color: #000000; ">(Object(node.view).
</span><span style="color: #008080; ">11</span> <span style="color: #000000; ">                hasOwnProperty(</span><span style="color: #000000; ">&quot;</span><span style="color: #000000; ">doubleClick</span><span style="color: #000000; ">&quot;</span><span style="color: #000000; ">))
</span><span style="color: #008080; ">12</span> <span style="color: #000000; ">            Object(node.view).doubleClick(</span><span style="color: #0000FF; ">event</span><span style="color: #000000; ">);
</span><span style="color: #008080; ">13</span> <span style="color: #000000; ">        }
</span><span style="color: #008080; ">14</span> <span style="color: #000000; ">        </span><span style="color: #0000FF; ">return</span><span style="color: #000000; ">;
</span><span style="color: #008080; ">15</span> <span style="color: #000000; ">    }
</span><span style="color: #008080; ">16</span> <span style="color: #000000; ">    lastMouseDownTime </span><span style="color: #000000; ">=</span><span style="color: #000000; "> now;
</span><span style="color: #008080; ">17</span> <span style="color: #000000; ">    </span><span style="color: #0000FF; ">if</span><span style="color: #000000; "> (_canDragNodes)
</span><span style="color: #008080; ">18</span> <span style="color: #000000; ">        dragBegin(</span><span style="color: #0000FF; ">event</span><span style="color: #000000; ">);
</span><span style="color: #008080; ">19</span> <span style="color: #000000; ">    </span><span style="color: #0000FF; ">event</span><span style="color: #000000; ">.stopImmediatePropagation();
</span><span style="color: #008080; ">20</span> <span style="color: #000000; ">}</span></div>
</pre>
</div>
<p>Beyond the addition of line 17, the only other thing I needed to add was one parameter _canDragNodes ( and its&#8217; getter and setter methods ).&nbsp; Although it is truly tons of fun to drag the seed member of the graph around and watch all their Twitter Friends fly after them &#8212; it&#8217;s not really useful.</p>
<p>If you want to see it running live, meaning you really think I&#8217;m a liar, here is&nbsp;a link to the Current Version of <a href="http://www.danmcweeney.com/static/7degrees/sevenDegress_2.html">7DegreesOfTwitter</a>.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.danmcweeney.com/29/feed</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
		<item>
		<title>Extreme Programming to the Max</title>
		<link>http://blog.danmcweeney.com/28</link>
		<comments>http://blog.danmcweeney.com/28#comments</comments>
		<pubDate>Wed, 13 Jun 2007 04:45:56 +0000</pubDate>
		<dc:creator>dan</dc:creator>
				<category><![CDATA[Flex]]></category>
		<category><![CDATA[UI]]></category>

		<guid isPermaLink="false">http://blog.danmcweeney.com/28</guid>
		<description><![CDATA[I&#8217;ve always thought it would be interesting for people to see what a programmer goes through when creating a new system.&#160; Telling the world where you are getting stuck so others can learn from and/or laugh at your mistakes.&#160; It might also be interesting for people who create languages or frameworks to see a blow [...]]]></description>
			<content:encoded><![CDATA[<p>I&#8217;ve always thought it would be interesting for people to see what a programmer goes through when creating a new system.&nbsp; Telling the world where you are getting stuck so others can learn from and/or laugh at your mistakes.&nbsp; It might also be interesting for people who create languages or frameworks to see a blow by blow of someone learning a new programming language / toolkit &#8212; how many times do you get to see that!</p>
<p>I also have wanted to build a Twitter ( hanger-on ) application that shows you your web friends and&nbsp;their friends and their friends and so on&nbsp;&#8212; think <a href="http://www.geocities.com/theeac/bacon.html">6 Degrees of Kevin Bacon</a> but, for Twitter.&nbsp; I&#8217;ve thought about the visualizations for this and feel that Flex/Flash is the only way to go, which I luckily no nothing about!&nbsp; So, tonight is the first episode of stuff I wish I knew about Flex while building 7DegreesOfTwitter.</p>
<p>I will only be working on this at night and on the weekends so, progress will be slow and sometimes painful.&nbsp; I may even try and post nightly &#8220;builds&#8221; somewhere so people can see what I&#8217;m up to help give me pointers where required.</p>
<h3>A Plan</h3>
<p>Here is what i think the visualization should look like ( yes this was done in MS Paint,&nbsp;hopefully I am a better programmer then artist ):</p>
<p>&nbsp;<img style="border-top-width: 0px; border-left-width: 0px; border-bottom-width: 0px; border-right-width: 0px" height="240" alt="7degrees" src="http://blog.danmcweeney.com/wp-content/uploads/2007/06/7degrees-thumb.png" width="222" align="left" border="0"></p>
<p>Basically, you should see all your friends circled around your portrait then as you click on a friend it will shift the view so that your friend is now the focus on the screen, and you can&nbsp;move along your web of friends exploring other people&#8217;s connection.&nbsp; Obviously, this whole&nbsp;visualization is rife with opportunity.&nbsp;&nbsp;Adding some cool like the Mac doc magnify feature would be&nbsp;pretty cool, or even maybe have&nbsp;the whole thing look like a horizon instead of a flat&nbsp;web of people.</p>
<h3>First Day&nbsp;</h3>
<p>First thing to do&nbsp;is&nbsp;get two chunks of data out of Twitter using the <a href="http://groups.google.com/group/twitter-development-talk/web/api-documentation" target="_blank">Twitter API</a>.&nbsp; The first bit is your list of friends:</p>
</p>
<div class="wlWriterSmartContent" id="57F11A72-B0E5-49c7-9094-E3A15BD5B5E6:77b2a885-13bc-4a22-bae0-37ce2891eecc" contenteditable="false" style="padding-right: 0px; display: inline; padding-left: 0px; float: none; padding-bottom: 0px; margin: 0px; width: 436px; padding-top: 0px">
<pre style="background-color:White;">
<div><!--

Code highlighting produced by Actipro CodeHighlighter (freeware)

http://www.CodeHighlighter.com/

--><span style="color: #000000; ">    </span><span style="color: #0000FF; ">&lt;</span><span style="color: #800000; ">mx:Script</span><span style="color: #0000FF; ">&gt;</span><span style="color: #000000; ">
        </span><span style="color: #0000FF; ">&lt;![CDATA[</span><span style="color: #808080; ">
            import mx.rpc.events.FaultEvent;
            import mx.rpc.events.ResultEvent;
            public var myInfo:XML;
            public var friends:XML;
            private function onFriendsResult(result:ResultEvent):void{
                friends = XML(result.result);
            }
            private function onFriendsFault(result:FaultEvent):void{
                var error:XML;
                error = XML(result.fault);
            }

        </span><span style="color: #0000FF; ">]]&gt;</span><span style="color: #000000; ">

    </span><span style="color: #0000FF; ">&lt;/</span><span style="color: #800000; ">mx:Script</span><span style="color: #0000FF; ">&gt;</span><span style="color: #000000; ">

    </span><span style="color: #0000FF; ">&lt;</span><span style="color: #800000; ">mx:HTTPService </span><span style="color: #FF0000; ">id</span><span style="color: #0000FF; ">=&quot;friendsService&quot;</span><span style="color: #FF0000; ">
        url</span><span style="color: #0000FF; ">=&quot;http://twitter.com/statuses/friends/dan_mcweeney.xml&quot;</span><span style="color: #FF0000; ">
        resultFormat</span><span style="color: #0000FF; ">=&quot;e4x&quot;</span><span style="color: #FF0000; ">
        result</span><span style="color: #0000FF; ">=&quot;onFriendsResult(event)&quot;</span><span style="color: #FF0000; ">
        fault</span><span style="color: #0000FF; ">=&quot;onFriendsFault(event)&quot;</span><span style="color: #0000FF; ">/&gt;</span></div>
</pre>
</div>
<p>So basically, this is all it takes in Flex to get data from a web service and parse it into an XML document that is easily traversable.&nbsp; If you don&#8217;t know what E4X is neither did I &#8212; go read the <a href="http://en.wikipedia.org/wiki/E4X" target="_blank">Wikipedia entry about E4X</a>&nbsp;then have a look at the <a href="www.w3schools.com/e4x/default.asp" target="_blank">W3Schools Tutorial on E4X</a>.&nbsp; Just remember it&#8217;s actually a lot easier then you think, no big scary XSLTs here.&nbsp; The next thing to do was the other piece of data I need, in this case it&#8217;s your mug shot associated with your Twitter account:</p>
<p>&nbsp; </p>
<div class="wlWriterSmartContent" id="57F11A72-B0E5-49c7-9094-E3A15BD5B5E6:d8d8981c-b463-4869-adef-845d433b2ef0" contenteditable="false" style="padding-right: 0px; display: inline; padding-left: 0px; float: none; padding-bottom: 0px; margin: 0px; padding-top: 0px">
<pre style="background-color:White;">
<div><!--

Code highlighting produced by Actipro CodeHighlighter (freeware)

http://www.CodeHighlighter.com/

--><span style="color: #000000; ">&lt;</span><span style="color: #000000; ">mx:Application xmlns:mx</span><span style="color: #000000; ">=</span><span style="color: #000000; ">&quot;</span><span style="color: #000000; ">http://www.adobe.com/2006/mxml</span><span style="color: #000000; ">&quot;</span><span style="color: #000000; "> layout</span><span style="color: #000000; ">=</span><span style="color: #000000; ">&quot;</span><span style="color: #000000; ">absolute</span><span style="color: #000000; ">&quot;</span><span style="color: #000000; ">
creationComplete</span><span style="color: #000000; ">=</span><span style="color: #000000; ">&quot;</span><span style="color: #000000; ">friendsService.send()</span><span style="color: #000000; ">&quot;</span><span style="color: #000000; ">&gt;</span><span style="color: #000000; ">
    </span><span style="color: #000000; ">&lt;</span><span style="color: #000000; ">mx:Script</span><span style="color: #000000; ">&gt;</span><span style="color: #000000; ">
        </span><span style="color: #000000; ">&lt;!</span><span style="color: #000000; ">[CDATA[
            import mx.rpc.events.FaultEvent;
            import mx.rpc.events.ResultEvent;
            </span><span style="color: #0000FF; ">public</span><span style="color: #000000; "> var myInfo:XML;
            </span><span style="color: #0000FF; ">public</span><span style="color: #000000; "> var friends:XML;
            </span><span style="color: #0000FF; ">private</span><span style="color: #000000; "> function onFriendsResult(result:ResultEvent):</span><span style="color: #0000FF; ">void</span><span style="color: #000000; ">{
                friends </span><span style="color: #000000; ">=</span><span style="color: #000000; "> XML(result.result);
                myInfoService.send();
            }
            </span><span style="color: #0000FF; ">private</span><span style="color: #000000; "> function onFriendsFault(result:FaultEvent):</span><span style="color: #0000FF; ">void</span><span style="color: #000000; ">{
                var error:XML;
                error </span><span style="color: #000000; ">=</span><span style="color: #000000; "> XML(result.fault);
            }

            </span><span style="color: #0000FF; ">private</span><span style="color: #000000; "> function onMyInfoServiceResult(result:ResultEvent):</span><span style="color: #0000FF; ">void</span><span style="color: #000000; ">{
                myInfo </span><span style="color: #000000; ">=</span><span style="color: #000000; "> XML(result.result);
                myMug.source </span><span style="color: #000000; ">=</span><span style="color: #000000; "> myInfo.profile_image_url;
            }
            </span><span style="color: #0000FF; ">private</span><span style="color: #000000; "> function onMyInfoServiceFailed(result:FaultEvent):</span><span style="color: #0000FF; ">void</span><span style="color: #000000; ">{
                var error:XML;
                error </span><span style="color: #000000; ">=</span><span style="color: #000000; "> XML(result.fault);
            }
        ]]</span><span style="color: #000000; ">&gt;</span><span style="color: #000000; ">

    </span><span style="color: #000000; ">&lt;/</span><span style="color: #000000; ">mx:Script</span><span style="color: #000000; ">&gt;</span><span style="color: #000000; ">
    </span><span style="color: #000000; ">&lt;</span><span style="color: #000000; ">mx:HTTPService id</span><span style="color: #000000; ">=</span><span style="color: #000000; ">&quot;</span><span style="color: #000000; ">friendsService</span><span style="color: #000000; ">&quot;</span><span style="color: #000000; ">
                    url</span><span style="color: #000000; ">=</span><span style="color: #000000; ">&quot;</span><span style="color: #000000; ">http://twitter.com/statuses/friends/dan_mcweeney.xml</span><span style="color: #000000; ">&quot;</span><span style="color: #000000; ">
                    resultFormat</span><span style="color: #000000; ">=</span><span style="color: #000000; ">&quot;</span><span style="color: #000000; ">e4x</span><span style="color: #000000; ">&quot;</span><span style="color: #000000; ">
                    result</span><span style="color: #000000; ">=</span><span style="color: #000000; ">&quot;</span><span style="color: #000000; ">onFriendsResult(event)</span><span style="color: #000000; ">&quot;</span><span style="color: #000000; ">
                    fault</span><span style="color: #000000; ">=</span><span style="color: #000000; ">&quot;</span><span style="color: #000000; ">onFriendsFault(event)</span><span style="color: #000000; ">&quot;</span><span style="color: #000000; ">/&gt;</span><span style="color: #000000; ">
    </span><span style="color: #000000; ">&lt;</span><span style="color: #000000; ">mx:HTTPService id</span><span style="color: #000000; ">=</span><span style="color: #000000; ">&quot;</span><span style="color: #000000; ">myInfoService</span><span style="color: #000000; ">&quot;</span><span style="color: #000000; ">
                    url</span><span style="color: #000000; ">=</span><span style="color: #000000; ">&quot;</span><span style="color: #000000; ">http://twitter.com/users/show/dan_mcweeney.xml</span><span style="color: #000000; ">&quot;</span><span style="color: #000000; ">
                    resultFormat</span><span style="color: #000000; ">=</span><span style="color: #000000; ">&quot;</span><span style="color: #000000; ">e4x</span><span style="color: #000000; ">&quot;</span><span style="color: #000000; ">
                    result</span><span style="color: #000000; ">=</span><span style="color: #000000; ">&quot;</span><span style="color: #000000; ">onMyInfoServiceResult(event)</span><span style="color: #000000; ">&quot;</span><span style="color: #000000; ">
                    fault</span><span style="color: #000000; ">=</span><span style="color: #000000; ">&quot;</span><span style="color: #000000; ">onMyInfoServiceFailed(event)</span><span style="color: #000000; ">&quot;</span><span style="color: #000000; ">/&gt;</span><span style="color: #000000; ">
    </span><span style="color: #000000; ">&lt;</span><span style="color: #000000; ">mx:Image id</span><span style="color: #000000; ">=</span><span style="color: #000000; ">&quot;</span><span style="color: #000000; ">myMug</span><span style="color: #000000; ">&quot;</span><span style="color: #000000; "> source</span><span style="color: #000000; ">=</span><span style="color: #000000; ">&quot;&quot;</span><span style="color: #000000; "> horizontalCenter</span><span style="color: #000000; ">=</span><span style="color: #000000; ">&quot;</span><span style="color: #000000; ">0</span><span style="color: #000000; ">&quot;</span><span style="color: #000000; "> verticalCenter</span><span style="color: #000000; ">=</span><span style="color: #000000; ">&quot;</span><span style="color: #000000; ">0</span><span style="color: #000000; ">&quot;</span><span style="color: #000000; ">
                     width</span><span style="color: #000000; ">=</span><span style="color: #000000; ">&quot;</span><span style="color: #000000; ">48</span><span style="color: #000000; ">&quot;</span><span style="color: #000000; "> height</span><span style="color: #000000; ">=</span><span style="color: #000000; ">&quot;</span><span style="color: #000000; ">48</span><span style="color: #000000; ">&quot;</span><span style="color: #000000; ">/&gt;</span><span style="color: #000000; ">

</span><span style="color: #000000; ">&lt;/</span><span style="color: #000000; ">mx:Application</span><span style="color: #000000; ">&gt;</span></div>
</pre>
</div>
<p>Major additions here are a a new HTTPService to grab my information and also a small slight of hand to keep the two asynchronous services at least somewhat in sync.&nbsp; In the onFriendsResult function I call the next HTTPService.&nbsp; This is an easy way to create simple dependencies among asynchronous requests.</p>
<h3><font face="Verdana">The Layout</font></h3>
<p>I started tonight to try and write this myself &#8212; and I soon realized I was probably in over my head.&nbsp; I got up to the point where I am able to calculate the correct radius for a circle to easily hold all of the objects and then where their positions should be in radians around the circle.&nbsp; The thought of having to write this in Flex made me want to jump out a window, so I thought to myself &#8212; maybe someone has already done this. Just then the Red Sea was parted and the open source gods smiled upon me.&nbsp; Circle Layout was created by <a href="http://kuwamoto.org/" target="_blank">Sho Kuwamoto</a>, an Adobe Engineer, it does exactly what I want in terms of layout and some other snazzy stuff with drag and drop.&nbsp;&nbsp;Here is a&nbsp;<a href="http://examples.kuwamoto.org/DragTile/DragTile_step3/DragDrop.html" target="_blank">demo of the Circle Layout for Flex</a>&nbsp;just press the &#8220;Change to Circle&#8221; button to see what I am talking about.&nbsp; It&#8217;s a pretty impressive bit of code for my needs though I need to get rid of the drag and drop bits but, for right now I will leave all that in.</p>
<p>So here is the the running code for <a href="http://danmcweeney.com/static/7degrees/one/sevenDegress_1.html" target="_blank">Iteration 1 of the 7DegreesOfTwitter</a>.&nbsp; If you want the source just right-click the movie and use the &#8220;View Source&#8221; menu option.&nbsp; When asked for a username and password just use your Twitter Log-in info.</p>
<p>Current issues:</p>
<ul>
<li>Only works for me!
<li>No clue what will happen when you have lots of friends</li>
</ul>
<p>Next time?</p>
<ul>
<li>Create a hover over for the images to at least show the name
<li>Come up with a way of Clicking on a person then moving to their &#8220;circle&#8221;</li>
</ul>
<p>If you find more issues in the code just post a comment &#8212; if I&#8217;m doing something totally silly please tell me that too!</p>
<h5>Once again big thanks to <a href="http://kuwamoto.org/" target="_blank">Sho Kuwamoto</a>&nbsp;for saving me having to do any real programming <img src='http://blog.danmcweeney.com/wp-includes/images/smilies/icon_smile.gif' alt=':-)' class='wp-smiley' /> </h5>
]]></content:encoded>
			<wfw:commentRss>http://blog.danmcweeney.com/28/feed</wfw:commentRss>
		<slash:comments>8</slash:comments>
		</item>
		<item>
		<title>Flex and SAP, initial impression</title>
		<link>http://blog.danmcweeney.com/26</link>
		<comments>http://blog.danmcweeney.com/26#comments</comments>
		<pubDate>Tue, 12 Jun 2007 01:07:30 +0000</pubDate>
		<dc:creator>dan</dc:creator>
				<category><![CDATA[Flex]]></category>
		<category><![CDATA[SAP]]></category>
		<category><![CDATA[SDN blogger]]></category>

		<guid isPermaLink="false">http://blog.danmcweeney.com/26</guid>
		<description><![CDATA[I have to admit developing in Flex makes life very easy. It is very simple to get something going quickly and link it to simple web services. The internal help inside the Flex builder is a great start when you are finding your way and the &#8220;Live Docs&#8221; web based documentation is really great at [...]]]></description>
			<content:encoded><![CDATA[<p>I have to admit developing in Flex makes life very easy.  It is very simple to get something going quickly and link it to simple web services.  The internal help inside the Flex builder is a great start when you are finding your way and the &#8220;<a href="http://livedocs.adobe.com/flex/2/docs/Part2_DevApps.html">Live Docs</a>&#8221; web based documentation is really great at filling in more complex holes.</p>
<p>It&#8217;s an Adobe( formerly Macromedia product ) so creating very attractive user interfaces is so easy, especially when compared to most SAP delivered options.  The best comparison I guess for Flex Builder would be WebDynpros as you can quickly throw together a UI and bind data to it.  However, unlike WebDynpro the delivered Flex components are extendable and skinnable.  Not only that but you can go as far to <a href="http://weblogs.macromedia.com/pent/archives/2006/07/writing_flex_2.cfm">build your own Flex components</a> and use existing <a href="http://code.google.com/p/flexlib/">open source libraries of Flex components</a>.  So your options are really limitless.</p>
<p>In working with the tool for a few days the ability to &#8220;have your cake and eat it too&#8221; in Flex is really nice.  You have the ability to do most simple tasks via MXML, the Flex version of a UI layout language, but when you need to really affect how the component responds you can sub-class it in AS and do whatever you want to it.</p>
<p>If you plan on working with Flex and SAP, get Flex 3.  The webservice handling in Flex 2 was not very good when used with complex types in webservices.  I was losing whole outbound parameters &#8212; not good.  However, after downloading Flex 3 its seems they have fixed all these problems.</p>
<p>Some of the documentation is still a little disorganized.  I found it really hard to find examples of the Advanced Datagrid but, I am in a giving mood so here is the direct link to download <a href="http://download.macromedia.com/pub/labs/flex/3/featuresamples/advanceddatagrid_beta1.zip">Advanced DataGrid Examples</a>, thanks to the <a href="http://groups.yahoo.com/group/flexcoders/">Yahoo! Flexcoders group</a> for handing that out.  I am sure as they move forward they will better integrate their documentation.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.danmcweeney.com/26/feed</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
	</channel>
</rss>

