<?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>hasseg.org &#187; Flex</title>
	<atom:link href="http://hasseg.org/blog/post/category/flex/feed/" rel="self" type="application/rss+xml" />
	<link>http://hasseg.org/blog</link>
	<description></description>
	<lastBuildDate>Sun, 29 Apr 2012 09:35:56 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.2</generator>
		<item>
		<title>Getting a List of Installed Fonts with Flash and Javascript</title>
		<link>http://hasseg.org/blog/post/526/getting-a-list-of-installed-fonts-with-flash-and-javascript/</link>
		<comments>http://hasseg.org/blog/post/526/getting-a-list-of-installed-fonts-with-flash-and-javascript/#comments</comments>
		<pubDate>Mon, 12 Jul 2010 23:18:05 +0000</pubDate>
		<dc:creator>Ali Rantakari</dc:creator>
				<category><![CDATA[ActionScript 3]]></category>
		<category><![CDATA[Flex]]></category>
		<category><![CDATA[Miscallaneous]]></category>
		<category><![CDATA[Programming]]></category>

		<guid isPermaLink="false">http://hasseg.org/blog/?p=526</guid>
		<description><![CDATA[When implementing the feature in the icalBuddy examples page where the font used for the output examples could be changed interactively I needed to get a list of all the fonts installed on the current user&#8217;s computer. This blog post from 2006 explains how to do it, but it refers to the deprecated ActionScript 2 [...]]]></description>
			<content:encoded><![CDATA[<p>
<img src="http://hasseg.org/blog/wp-content/uploaded/2010/07/flash-fonts.png" alt="" title="" width="90" height="104" align="right" /> When implementing the feature in the <a href="/icalBuddy/examples.html">icalBuddy examples page</a> where the font used for the output examples could be changed interactively I needed to <strong>get a list of all the fonts installed on the current user&#8217;s computer</strong>. <a href="http://www.maratz.com/blog/archives/2006/08/18/detect-visitors-fonts-with-flash/">This blog post from 2006</a> explains how to do it, but it refers to the deprecated ActionScript 2 API so I had to figure out how to do it with AS3.
</p>
<p><span id="more-526"></span></p>
<h3>Demo</h3>
<p>
Here&#8217;s a small demo where you can see the feature at work: <a href="/stuff/fontList/example.html">Font List Example</a>. The sources shown below are used in this demo.
</p>
<h3>Implementation</h3>
<p>
We need <strong>a small Flash app and some Javascript</strong>. Below is the source code for the Flash app.
</p>
<p>
<em>Note that you don&#8217;t need the Flash authoring app from Adobe in order to compile this; you can simply use the <span style="font-family:monospace;">mxmlc</span> compiler in the <a href="http://opensource.adobe.com/wiki/display/flexsdk/">Flex SDK</a> (which is open source).</em>
</p>
<div class="codecolorer-container actionscript mac-classic codecolorer-customstyle" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><div class="actionscript codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color: #808080; font-style: italic;">// FontList.as</span><br />
package <span style="color: #66cc66;">&#123;</span><br />
&nbsp; &nbsp; <br />
&nbsp; &nbsp; <span style="color: #0066CC;">import</span> flash.<span style="color: #006600;">display</span>.<span style="color: #006600;">Sprite</span>;<br />
&nbsp; &nbsp; <span style="color: #0066CC;">import</span> flash.<span style="color: #0066CC;">text</span>.<span style="color: #0066CC;">Font</span>;<br />
&nbsp; &nbsp; <span style="color: #0066CC;">import</span> flash.<span style="color: #0066CC;">text</span>.<span style="color: #006600;">FontType</span>;<br />
&nbsp; &nbsp; <span style="color: #0066CC;">import</span> flash.<span style="color: #0066CC;">text</span>.<span style="color: #006600;">FontStyle</span>;<br />
&nbsp; &nbsp; <span style="color: #0066CC;">import</span> flash.<span style="color: #006600;">external</span>.<span style="color: #006600;">ExternalInterface</span>;<br />
&nbsp; &nbsp; <br />
&nbsp; &nbsp; <span style="color: #0066CC;">public</span> <span style="color: #000000; font-weight: bold;">class</span> FontList <span style="color: #0066CC;">extends</span> Sprite<br />
&nbsp; &nbsp; <span style="color: #66cc66;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0066CC;">public</span> <span style="color: #000000; font-weight: bold;">function</span> FontList<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #66cc66;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; ExternalInterface.<span style="color: #0066CC;">call</span><span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">'populateFontList'</span>, getDeviceFonts<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #66cc66;">&#125;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0066CC;">public</span> <span style="color: #000000; font-weight: bold;">function</span> getDeviceFonts<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>:<span style="color: #0066CC;">Array</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #66cc66;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">var</span> embeddedAndDeviceFonts:<span style="color: #0066CC;">Array</span> = <span style="color: #0066CC;">Font</span>.<span style="color: #006600;">enumerateFonts</span><span style="color: #66cc66;">&#40;</span><span style="color: #000000; font-weight: bold;">true</span><span style="color: #66cc66;">&#41;</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">var</span> deviceFontNames:<span style="color: #0066CC;">Array</span> = <span style="color: #66cc66;">&#91;</span><span style="color: #66cc66;">&#93;</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #b1b100;">for</span> <span style="color: #b1b100;">each</span> <span style="color: #66cc66;">&#40;</span><span style="color: #000000; font-weight: bold;">var</span> <span style="color: #0066CC;">font</span>:<span style="color: #0066CC;">Font</span> <span style="color: #b1b100;">in</span> embeddedAndDeviceFonts<span style="color: #66cc66;">&#41;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #66cc66;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #b1b100;">if</span> <span style="color: #66cc66;">&#40;</span><span style="color: #0066CC;">font</span>.<span style="color: #006600;">fontType</span> == FontType.<span style="color: #006600;">EMBEDDED</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #66cc66;">||</span> <span style="color: #0066CC;">font</span>.<span style="color: #006600;">fontStyle</span> <span style="color: #66cc66;">!</span>= FontStyle.<span style="color: #006600;">REGULAR</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #66cc66;">&#41;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #b1b100;">continue</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; deviceFontNames.<span style="color: #0066CC;">push</span><span style="color: #66cc66;">&#40;</span><span style="color: #0066CC;">font</span>.<span style="color: #006600;">fontName</span><span style="color: #66cc66;">&#41;</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #66cc66;">&#125;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; deviceFontNames.<span style="color: #0066CC;">sort</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #b1b100;">return</span> deviceFontNames;<br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #66cc66;">&#125;</span><br />
&nbsp; &nbsp; <span style="color: #66cc66;">&#125;</span><br />
<span style="color: #66cc66;">&#125;</span></div></div>
<p>
Notice how the Flash app calls a Javascript function <span style="font-family:monospace;">populateFontList()</span> via the ExternalInterface. Now we just need to implement that function in the page where we embed the Flash object:
</p>
<div class="codecolorer-container javascript mac-classic codecolorer-customstyle" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><div class="javascript codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color: #003366; font-weight: bold;">function</span> populateFontList<span style="color: #009900;">&#40;</span>fontArr<span style="color: #009900;">&#41;</span><br />
<span style="color: #009900;">&#123;</span><br />
&nbsp; &nbsp; <span style="color: #000066; font-weight: bold;">for</span> <span style="color: #009900;">&#40;</span><span style="color: #003366; font-weight: bold;">var</span> key <span style="color: #000066; font-weight: bold;">in</span> fontArr<span style="color: #009900;">&#41;</span><br />
&nbsp; &nbsp; <span style="color: #009900;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #003366; font-weight: bold;">var</span> fontName <span style="color: #339933;">=</span> fontArr<span style="color: #009900;">&#91;</span>key<span style="color: #009900;">&#93;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #006600; font-style: italic;">// trim</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; fontName <span style="color: #339933;">=</span> fontName.<span style="color: #660066;">replace</span><span style="color: #009900;">&#40;</span><span style="color: #009966; font-style: italic;">/^\s\s*/</span><span style="color: #339933;">,</span> <span style="color: #3366CC;">''</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">replace</span><span style="color: #009900;">&#40;</span><span style="color: #009966; font-style: italic;">/\s\s*$/</span><span style="color: #339933;">,</span> <span style="color: #3366CC;">''</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000066; font-weight: bold;">if</span> <span style="color: #009900;">&#40;</span>fontName.<span style="color: #660066;">match</span><span style="color: #009900;">&#40;</span><span style="color: #009966; font-style: italic;">/[_\-\s]Italic$/</span><span style="color: #009900;">&#41;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #339933;">||</span> fontName.<span style="color: #660066;">match</span><span style="color: #009900;">&#40;</span><span style="color: #009966; font-style: italic;">/[_\-\s](Demi)?[Bb]old$/</span><span style="color: #009900;">&#41;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #339933;">||</span> fontName.<span style="color: #660066;">match</span><span style="color: #009900;">&#40;</span><span style="color: #009966; font-style: italic;">/[_\-\s]Medium$/</span><span style="color: #009900;">&#41;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #339933;">||</span> fontName.<span style="color: #660066;">match</span><span style="color: #009900;">&#40;</span><span style="color: #009966; font-style: italic;">/[_\-\s](Ultra)?[Ll]ight$/</span><span style="color: #009900;">&#41;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #339933;">||</span> fontName.<span style="color: #660066;">match</span><span style="color: #009900;">&#40;</span><span style="color: #009966; font-style: italic;">/[_\-\s]Condensed$/</span><span style="color: #009900;">&#41;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900;">&#41;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #006600; font-style: italic;">// font is &quot;non-regular&quot; (i.e. bold, italic etc.)</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #006600; font-style: italic;">// (do something here with fontName)</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000066; font-weight: bold;">else</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #006600; font-style: italic;">// font is &quot;regular&quot;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #006600; font-style: italic;">// (do something here with fontName)</span><br />
&nbsp; &nbsp; <span style="color: #009900;">&#125;</span><br />
<span style="color: #009900;">&#125;</span></div></div>
]]></content:encoded>
			<wfw:commentRss>http://hasseg.org/blog/post/526/getting-a-list-of-installed-fonts-with-flash-and-javascript/feed/</wfw:commentRss>
		<slash:comments>10</slash:comments>
		</item>
		<item>
		<title>fcshctl: the Flex Compiler Shell Controller</title>
		<link>http://hasseg.org/blog/post/194/fcshctl-the-flex-compiler-shell-controller/</link>
		<comments>http://hasseg.org/blog/post/194/fcshctl-the-flex-compiler-shell-controller/#comments</comments>
		<pubDate>Mon, 03 Nov 2008 17:32:35 +0000</pubDate>
		<dc:creator>Ali Rantakari</dc:creator>
				<category><![CDATA[ActionScript 3]]></category>
		<category><![CDATA[Flex]]></category>
		<category><![CDATA[jEdit]]></category>
		<category><![CDATA[Programming]]></category>
		<category><![CDATA[Scripts]]></category>

		<guid isPermaLink="false">http://hasseg.org/blog/?p=194</guid>
		<description><![CDATA[Introduction Like I&#8217;ve mentioned before in this blog, I develop Flex applications using the Flex SDK and jEdit instead of Adobe&#8217;s Flex Builder IDE. This setup has worked very well for me but one annoying issue I&#8217;ve had to deal with because of this is the slow compilation speed: every time I make a small [...]]]></description>
			<content:encoded><![CDATA[<h2>Introduction</h2>
<p>
Like I&#8217;ve mentioned before in this blog, I develop Flex applications using the Flex SDK and jEdit instead of Adobe&#8217;s Flex Builder IDE. This setup has worked very well for me but one annoying issue I&#8217;ve had to deal with because of this is <strong>the slow compilation speed</strong>: every time I make a small change into one of my projects and recompile it, the mxmlc compiler (that my build scripts are calling) has to load the JVM into memory and recompile my whole project from scratch, which obviously takes a while. Compiling things in Flex Builder is a lot faster, and the reason for that is <em><a href="http://labs.adobe.com/wiki/index.php/Flex_Compiler_Shell">the Flex Compiler Shell</a></em>, which it uses for compilation instead of mxmlc.
</p>
<div style="padding:4px;background:#eee;border:1px solid #ddd;">
<em><strong>Update (Version 0.5.1, Mar 17, 09):</strong></p>
<ul>
<li>Display a &#8220;compiling&#8230;&#8221; message before sending fcsh a compilation command in order to let the user know that something is going on and that they should wait instead of just killing the process.</li>
<li>If the log file exists when fcshctl runs, check if there are any other fcshctl instances running, and if not, assume that the log file has been orphaned, delete it and continue.</li>
<li>Exit with status code 0 (&#8220;ok&#8221;) if fcsh output ends in the <em>&#8220;Nothing has changed since the last compile&#8221;</em> message.</li>
</ul>
<p></em>
</div>
<p><span id="more-194"></span></p>
<div style="padding:4px;background:#eee;border:1px solid #ddd;">
<em><br />
<strong>Update (Version 0.5, Dec 10, 08):</strong></p>
<ul>
<li>Made it possible to specify a filename as the argument to the &#8220;clear&#8221; command &#8212; fcshctl will then try to find the first compile target id matching the specified filename and clear the corresponding id (example: &#8220;fcshctl clear MyApp.mxml&#8221;)</li>
<li>Made fcshctl find compile target ids corresponding to specific filenames or paths by asking fcsh directly via the &#8220;info&#8221; command instead of retaining them on its own in a temporary file (this is in order to avoid problems that could arise if this temp file and fcsh&#8217;s own list of retained compile target ids would get out of sync.)</li>
<li>Added command &#8220;id&#8221; which can be used to find the first compile target id matching a specified string (example: &#8220;fcshctl id MyApp.mxml&#8221;)</li>
</ul>
<p><strong>Update (Version 0.4, Nov 4, 08):</strong></p>
<ul>
<li>Made the script use only one logfile (i.e. one with a static path) and check its existence (and if it does exist, wait for it to be deleted) before continuing, so as to make sure no two fcshctl instances can try to send commands to fcsh at the same time, or before an already running command has finished executing and returned control to the prompt.</li>
</ul>
<p></em>
</div>
<p></p>
<p>
The basic idea behind the Flex Compiler Shell is that it would stay in memory between compilations (thus avoiding the cost of loading up the JVM every time you want to compile something) and use a technique called <strong>incremental compilation</strong> that, as the name suggests, is based on the idea of only compiling the parts of your project that have changed since the last compilation (thus making the process a lot faster). When you run the Flex Compiler Shell executable (called <em>fcsh</em>), you&#8217;re thrown into an interactive shell where you can run commands in order to compile your projects and control the operation of fcsh itself.
</p>
<h2>The Problem</h2>
<p>
When I found out about fcsh, tried it out and saw how much faster it was than mxmlc, of course I wanted to immediately start using it instead in my build scripts. The biggest problem with doing this, though, is the fact that <strong>the basic operation of these two programs is fundamentally different</strong>: when you run mxmlc, it compiles the project, prints some messages to standard output and then exits (with the exit status 0 if the compilation was successful or 1 if it wasn&#8217;t), which is perfect for integrating it into build scripts. Fcsh, on the other hand, throws you into a shell of its own and expects you to essentially operate it from within itself (instead of simply calling it with some arguments and then having it return with some standard output and an exit status like mxmlc).
</p>
<p>
The other issue that makes fcsh more difficult to use in general is that in order to use the incremental compilation feature, you have to first compile your project like you normally would (using the &#8220;mxmlc&#8221; command), then make note of the <em>&#8220;compile target id&#8221;</em> number that fcsh then assigns to this project and specifies in its output, and for future compilations use the &#8220;compile N&#8221; (where N is the compile target id) command.
</p>
<h2>The Solution</h2>
<p>
I tried to search for a solution to this problem that somebody else might have come up with but didn&#8217;t find an adequate one (a list of the ones that I could find is further down), so I decided to give it a shot myself. My approach, called <strong>fcshctl</strong> (short for &#8220;fcsh controller&#8221;), is basically a simple bash script that:</p>
<ol>
<li>starts the fcsh process if it isn&#8217;t already running</li>
<li>forwards its arguments to fcsh as commands</li>
<li>reads the output of that command from the fcsh interactive shell and prints it to the standard output</li>
<li>exits with status 0 (success) or >0 (failure)</li>
</ol>
<p>
In addition to this, I also made the script <strong>automatically and transparently invoke the incremental compilation feature</strong> whenever applicable so that I wouldn&#8217;t have to worry about keeping track of the compile target ids and using a different command for the compilation whenever one had already been assigned.
</p>
<p>
Below is a summarization of the pros and cons of this solution:
</p>
<h3>Pros:</h3>
<ul>
<li>It&#8217;s quite simple &#8212; just one shell script (a few others are included in the .zip that are only for convenience and not required)</li>
<li>It runs the fcsh instance in a <a href="http://www.gnu.org/software/screen/">GNU screen</a> session, which means that:</li>
<ul>
<li>The running fcsh instance is accessible to all user processes (i.e. not just within a single shell session, for example)</li>
<li>It is possible for the user to enter the running fcsh interactive shell at any time (by attaching to the screen session via the command <span style="font-family:monospace;">screen -r -S fcsh</span>) and manually interact with it</li>
</ul>
<li>It automatically checks whether you&#8217;ve compiled a specific file before and keeps track of the compile target ids that fcsh assigns so that it can automatically and transparently invoke the incremental compilation feature and let you access the speed gains that are fcsh&#8217;s main offering without any additional work. This feature can also be turned off by setting an environment variable.</li>
<li>A proxy script (called <span style="font-family:monospace;">fcshctl-mxmlc</span>) that can be used in place of mxmlc is provided. It simply calls fcshctl with <span style="font-family:monospace;">&#8220;mxmlc&#8221;</span> as the first argument, followed by all the other arguments you specify, so that you can simply use this script as a stand-in for mxmlc in any build scripts that you may be using without having to modify them any further.</li>
</ul>
<h3>Cons:</h3>
<ul>
<li>It uses the GNU screen logging mechanism and polling for changes in the log file in order to catch the output of commands sent to fcsh, which is not very elegant and causes a slowdown of maybe about a couple hundred milliseconds before the output is printed to stdout.</li>
<li>The output of the executed fcsh command is not printed to the standard output as it comes, but instead all at once when the command finishes (this is not a problem for me personally, but others might want to fix this).</li>
<li>It&#8217;s implemented as a bash script, which means that it&#8217;s not the fastest monster out there (we&#8217;re talking about milliseconds here, though, so it doesn&#8217;t bother me at all).</li>
</ul>
<h2>Download</h2>
<p>
You can download fcshctl here:</p>
<ul>
<li><strong><a href="/stuff/fcshctl/fcshctl-v0.5.1.zip">fcshctl-v0.5.1.zip</a> (latest)</strong></li>
<li><a href="/stuff/fcshctl/fcshctl-v0.5.zip">fcshctl-v0.5.zip</a></li>
<li><a href="/stuff/fcshctl/fcshctl-v0.4.zip">fcshctl-v0.4.zip</a></li>
<li><a href="/stuff/fcshctl/fcshctl-v0.3.zip">fcshctl-v0.3.zip</a></li>
</ul>
<p>
fcshctl has been tested with fcsh versions <em>3.0.0 build 477</em> and <em>3.1.0 build 2710</em> on Mac OS 10.5.5. It is licensed under <a href="http://hasseg.org/stuff/license/MIT_License.txt">the MIT License</a>.
</p>
<p>
The script requires the following to be in your <span style="font-family:monospace;">$PATH</span>: rm, mv, cat, ps, sleep, tail, head, grep, awk, screen, xargs and basename. <strong>You also need to have the <span style="font-family:monospace;">FLEX_HOME</span> environment variable set to point to the Flex SDK root path.</strong>
</p>
<h2>Example of use</h2>
<p><pre>
fcshctl $ export FLEX_HOME=/Users/username/code/SDKs/flex_sdk_3.1
fcshctl $
fcshctl $ ./fcshctl
<span style="color:blue;">
Usage: fcshctl &lt;commands&gt;

&nbsp;&nbsp;Substitute &lt;commands&gt; with any commands you
&nbsp;&nbsp;would like to send fcsh, just like you would
&nbsp;&nbsp;enter them in the interactive fcsh shell
&nbsp;&nbsp;session.

&nbsp;&nbsp;To get a list of the available commands, run:

&nbsp;&nbsp;&nbsp;&nbsp;fcshctl help
</span>
fcshctl $
fcshctl $ ./fcshctl help
<span style="color:blue;">List of fcsh commands:
mxmlc arg1 arg2 ...      full compilation and optimization; return a target id
compc arg1 arg2 ...      full SWC compilation
compile id               incremental compilation
clear [id]               clear target(s)
info [id]                display compile target info
quit                     quit</span>
fcshctl $
fcshctl $ ./fcshctl mxmlc ~/code/Flex/projects/testbed/testbed.mxml
<span style="color:blue;">Loading configuration file /Users/username/code/SDKs/flex_sdk_3.1/frameworks/flex-config.xml
Recompile: /Users/username/code/Flex/projects/testbed/testbed.mxml
Reason: The source file wasn't fully compiled.
Files changed: 0 Files affected: 1
/Users/username/code/Flex/projects/testbed/testbed.mxml(28):  Error: Incorrect number of arguments.  Expected 2.

&nbsp;&nbsp;&nbsp;&nbsp;func1("toka");
</span>
fcshctl $ echo $?
1
fcshctl $
fcshctl $
</pre>
</p>
<h2>Other similar solutions</h2>
<p>
Below is a list of other approaches to the problem of integrating fcsh to non-standard (i.e. non-Flex Builder) workflows (roughly in order from most promising to least promising), and short lists of reasons why I personally didn&#8217;t want to use them. If my solution doesn&#8217;t seem good to you, you should maybe check some of these out.
</p>
<p>
<a href="http://www.vim.org/scripts/script.php?script_id=1793">fcsh tools</a> by <em>Mike Rowe</em></p>
<ul>
<li>Runs fcsh in a daemonized process, which means you won&#8217;t be able to enter the interactive shell of a running fcsh process and manually interact with it</li>
<li>You can only specify the filename to compile; has no support for additional mxmlc arguments</li>
<li>For GNU/Linux (but seems to work just fine on OS X as well)</li>
</ul>
<p><a href="http://code.google.com/p/flex-compiler-shell-daemon/">flex-compiler-shell-daemon</a> by <em>Leonardo Soto Muños</em> (also see <a href="http://blog.leosoto.com/2008/10/flex-compiler-shell-daemon.html">his blog post about it</a>)</p>
<ul>
<li>I couldn&#8217;t get it to work out of the box on OS X</li>
<li>Runs fcsh in a daemonized process, which means you won&#8217;t be able to enter the interactive shell of a running fcsh process and manually interact with it</li>
</ul>
<p><a href="http://fcshwrapper.blogspot.com/">FCSH Wrapper</a> by <em>Mihai Vasilache</em></p>
<ul>
<li>For Windows</li>
<li>Designed to be used with Ant</li>
<li><a href="http://mihai.vasilache.googlepages.com/classDiagram.jpg">A bit complicated</a></li>
</ul>
<p><a href="http://code.google.com/p/fsch/">http://code.google.com/p/fsch/</a> by <em>nimrod97</em></p>
<ul>
<li>For Windows</li>
</ul>
<p><a href="http://zarkov.bigsource.de/front_content.php">BigSource Zarkov</a> by <em>BigSource GbR</em></p>
<ul>
<li>For Eclipse &#038; Ant</li>
</ul>
]]></content:encoded>
			<wfw:commentRss>http://hasseg.org/blog/post/194/fcshctl-the-flex-compiler-shell-controller/feed/</wfw:commentRss>
		<slash:comments>21</slash:comments>
		</item>
		<item>
		<title>Saving and Accessing Version/Compilation Information with Flex Applications</title>
		<link>http://hasseg.org/blog/post/165/saving-and-accessing-versioncompilation-information-with-flex-applications/</link>
		<comments>http://hasseg.org/blog/post/165/saving-and-accessing-versioncompilation-information-with-flex-applications/#comments</comments>
		<pubDate>Mon, 29 Sep 2008 13:52:22 +0000</pubDate>
		<dc:creator>Ali Rantakari</dc:creator>
				<category><![CDATA[ActionScript 3]]></category>
		<category><![CDATA[Flex]]></category>
		<category><![CDATA[Programming]]></category>

		<guid isPermaLink="false">http://hasseg.org/blog/?p=165</guid>
		<description><![CDATA[On several occasions while developing Flash applications I&#8217;ve run into problems with proxy/cache servers. The pattern is usually something like this: I notice a bug in an application that only occurs when running it on the server I debug the application, find the bug and issue a fix I deploy the new version that contains [...]]]></description>
			<content:encoded><![CDATA[<p>
On several occasions while developing Flash applications I&#8217;ve run into problems with proxy/cache servers. The pattern is usually something like this:</p>
<ol>
<li>I notice a bug in an application that only occurs when running it on the server</li>
<li>I debug the application, find the bug and issue a fix</li>
<li>I deploy the new version that contains the fix onto the server</li>
<li>I empty the browser cache and run the app on the server again, noticing that the bug seems to persist</li>
<li>I wonder if the version I&#8217;m seeing is indeed the version that has the fix, or an older build served to me by some cache server between my workstation and the server</li>
<li>I have to resort to stupid trickery (comparing md5 hashes of .swfs or something) in order to find out</li>
</ol>
<p><span id="more-165"></span></p>
<p>
The obvious solution to this problem is to make some sort of version information (that changes on each build) accessible to the application itself so that it can print it into the log or display it in the UI. As of Flex 3, this is quite easy to do with the <a href="http://livedocs.adobe.com/flex/3/html/compilers_21.html">conditional compilation</a> feature in the mxmlc compiler.
</p>
<p>
Due to the kinds of problems I&#8217;ve described above, I&#8217;ve taken up the practice of injecting a specific kind of string into my Flex apps at compilation time, containing the <strong>date and time</strong> of <em>when</em> it was compiled, as well as the <strong>hostname</strong> of the computer <em>where</em> it was compiled (and even though I only started this practice due to this specific problem that I was trying to solve, I believe saving version information into the build product should be standard practice for all kinds of software). An example of how I do this follows:</p>
<ol>
<li>Compile the binary with the conditional compilation parameter:</li>
<pre class="prettyprint">
/path/to/mxmlc -define+=DEBUG::compiled,"Fri_Sep_12_17:26:13_on_Alis-MacBook.local" -strict=true /path/to/myApp.mxml
</pre>
<li>Print out the &#8220;compiled&#8221; value in the application code:</li>
<pre class="prettyprint">
var DEBUG:Namespace = new Namespace("DEBUG");
var compiledStr:String = DEBUG::compiled;
trace("SWF was compiled: "+compiledStr);
</pre>
</ol>
<p>
Of course, for this to actually be useful, you somehow need to be able to automate the creation of this &#8220;compiled&#8221; string value. Here are some example scripts that show how to go about doing this:</p>
<ul>
<li><strong>Bourne shell script:</strong></li>
<pre class="prettyprint">
#!/bin/sh
#
# Compiles myApp
# 

if [ -n "${1}" ] &#038;&#038; [ -e "${1}" ];then

	DEBUGARG=""
	if [ -n "${2}" ] &#038;&#038; [ "${2}" == "debug" ];then
		DEBUGARG=" -compiler.debug"
	fi

	DN=`dirname ${1}`
	BN=`basename ${1}`
	MXMLC="`cd ${DN}; pwd`/${BN}"

	DN=`dirname ${0}`
	THISDIR="`cd ${DN}; pwd`"

	HOSTNAME="unknown"
	HOSTNAME="`hostname`"
	HOSTNAME=${HOSTNAME// /_}
	HOSTNAME=${HOSTNAME//\"/}
	HOSTNAME=${HOSTNAME//\'/}

	CURRDATESTR="`date`"
	CURRDATESTR=${CURRDATESTR// /_}
	MXMLC_WITH_ARGS="${MXMLC}${DEBUGARG} -define+=DEBUG::compiled,\"${CURRDATESTR}_on_${HOSTNAME}\" -strict=true"
	${MXMLC_WITH_ARGS} "${THISDIR}/myApp.mxml"

else

	echo "Usage: `basename \"${0}\"`
<path-to-mxmlc> [debug]"
	echo ""
	echo " The debug argument is optional. It specifies whether or not"
	echo " to compile a debug binary."
	echo ""
	exit 10

fi
</pre>
<li><strong>Windows batch file:</strong></li>
<pre class="prettyprint">
@ECHO OFF

REM check arguments -----------------
REM ---------------------------------
IF "%1"=="" GOTO ShowUsage
IF NOT EXIST %1 GOTO ShowMxmlcDoesntExistError

REM get datetime &#038; hostname -----------------
REM ---------------------------------
For /F "Tokens=2" %%I in ('Date /T') Do Set StrDate=%%I
For /F "Tokens=*" %%I in ('Time /T') Do Set StrTime=%%I
For /F "Tokens=*" %%I in ('hostname') Do Set StrHostname=%%I

Set StrCompiled=%StrDate%_%StrTime%_on_%StrHostname%

REM compile app -----------------
REM ---------------------------------
IF "%2"=="debug" (
	@ECHO ON
	%1 -compiler.debug -define+="DEBUG::compiled,\"%StrCompiled%\"" -strict=true myApp.mxml
	@ECHO OFF
) ELSE (
	@ECHO ON
	%1 -define+="DEBUG::compiled,\"%StrCompiled%\"" -strict=true myApp.mxml
	@ECHO OFF
)

GOTO EOF

:ShowUsage
echo Usage: %0 [path-to-mxmlc] [debug]
echo.
echo  The debug argument is optional. It specifies whether
echo  or not to compile a debug binary.
echo.
GOTO EOF

:ShowMxmlcDoesntExistError
echo Error: Specified path does not exist:
echo %1
GOTO EOF

:EOF
</pre>
</ul>
]]></content:encoded>
			<wfw:commentRss>http://hasseg.org/blog/post/165/saving-and-accessing-versioncompilation-information-with-flex-applications/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Mac OS X Mouse Wheel Support for ActionScript 3 Flash Applications (v.2+)</title>
		<link>http://hasseg.org/blog/post/138/os-x-mouse-wheel-support-for-actionscript-3-flash-applications-v2/</link>
		<comments>http://hasseg.org/blog/post/138/os-x-mouse-wheel-support-for-actionscript-3-flash-applications-v2/#comments</comments>
		<pubDate>Sat, 26 Apr 2008 19:35:41 +0000</pubDate>
		<dc:creator>Ali Rantakari</dc:creator>
				<category><![CDATA[ActionScript 3]]></category>
		<category><![CDATA[Flex]]></category>
		<category><![CDATA[Mac]]></category>
		<category><![CDATA[Programming]]></category>

		<guid isPermaLink="false">http://hasseg.org/blog/?p=138</guid>
		<description><![CDATA[So I&#8217;ve finally updated the solution I&#8217;ve made earlier for enabling Mac OS X mouse wheel support in Flex applications to a second version. I didn&#8217;t want to continue adding stuff into the original post, so I decided to write a separate post just for this new version. As you can see from the title, [...]]]></description>
			<content:encoded><![CDATA[<p>
<img align="right" src='http://hasseg.org/blog/wp-content/uploaded/2008/04/as3mousewheel.png' alt='AS3 Mouse Wheel support picture' /> So I&#8217;ve finally updated <a href="?p=3">the solution I&#8217;ve made earlier for enabling Mac OS X mouse wheel support in Flex applications</a> to a second version. I didn&#8217;t want to continue adding stuff into the original post, so I decided to write a separate post just for this new version. As you can see from the title, this version should work in any Flash project you&#8217;re writing in ActionScript 3, as opposed to just in Flex projects. This change was contributed by <a href="http://inreflected.com">Pavel Fljot</a>, and all the other stuff I&#8217;ve added since have been added on top of that. Deployment should now be a lot easier and some features that were missing in the first version have also been added.
</p>
<p><span id="more-138"></span></p>
<h3>Changelog</h3>
<p>
First, here is an itemized list of what has changed:</p>
<ul>
<li><strong>Flex dependencies have been removed, which makes it possible to use this in pure AS3 projects as well</strong></li>
<p><em>This changes the way the support is initialized in AS3, but more about that a bit later. Courtesy of <a href="http://inreflected.com">Pavel Fljot</a>.</em></p>
<li><strong>States of modifier keys (i.e. ctrl (or command in OS X,) alt, shift) are supported</strong></li>
<p><em>These can be accessed via the ctrlKey, altKey and shiftKey properties in the MouseEvent object, as usual.</em></p>
<li><strong>The initialization of the code on the JavaScript end requires much less effort</strong></li>
<p><em>You basically just have to include the one JavaScript file on the page and that&#8217;s it.</em></p>
<li><strong>An another method of determining which object on the Stage should dispatch the mouse wheel event has been added</strong></li>
<p><em>Read more about this below. Courtesy of a similar solution from <a href="http://blog.pixelbreaker.com/flash/as30-mousewheel-on-mac-os-x/">Gabriel Bucknall</a>.</em></p>
<li><strong>Is enabled for Safari for Windows</strong></li>
<p><em>For some mysterious reason the mouse wheel won&#8217;t work in Flash when accessed with the Windows version of Safari, so this solution will now enable itself for that browser. Courtesy of <a href="http://inreflected.com">Pavel Fljot</a>.</em></p>
<li><strong>Can be enabled for any number of different Flash objects on the same page</strong></li>
<p><em>As long as the JavaScript file is linked on the page and the Flash apps have initialized the AS3 end of the code, they should be supported.</em></p>
<li><strong>The JavaScript code is encapsulated inside one top-level function</strong></li>
<p><em>This is a much more elegant solution on the JavaScript end. Courtesy of a similar solution from <a href="http://blog.pixelbreaker.com/flash/as30-mousewheel-on-mac-os-x/">Gabriel Bucknall</a>.</em></p>
<li><strong>The initialization state of the mouse wheel support is exposed</strong></li>
<p><em>You can read the value of the &#8220;initialized&#8221; property (or bind to it) to see if the mouse wheel support has been initialized.</em></p>
<li><strong>The concept of &#8220;registering and unregistering objects&#8221; for mouse wheel support within AS3 code has been removed</strong></li>
<p><em>This concept is no longer useful, given the new implementation.</em></p>
</ul>
<h3>Determining the InteractiveObject to dispatch the mouse wheel event</h3>
<p>
Like mentioned in the changelog above, I&#8217;ve added an another method for finding the <em>InteractiveObject</em> on stage and under the mouse cursor that should dispatch the mouse wheel event when one is sent from the JavaScript end. This is based on the solution to this same issue Gabriel Bucknall has come up with at <a href="http://blog.pixelbreaker.com/flash/as30-mousewheel-on-mac-os-x/">pixelbreaker.com</a>. My solution basically went through the whole display list hierarcy every time a mouse wheel event had to be dispatched, trying to find mouse-enabled InteractiveObjects that were under the mouse cursor, and then asked the topmost of these to dispatch the <em>MouseEvent</em>. Gabriel&#8217;s solution was to attach a <em>MouseEvent.MOUSE_MOVE</em> event listener to the Stage and keep a reference to the object that was the target for the last such event, and then use that reference to ask this object to dispatch the mouse wheel event whenever required.
</p>
<p>
Now, the main difference between these two solutions, I&#8217;ve found, is that Gabriel&#8217;s is faster but inaccurate in some border cases, while mine is slower but more accurate. The slowness of my solution is very clear if you understand the amount of processing that goes on whenever the user starts rolling the wheel: for each event, the application needs to go through the whole hierarchy of objects on the Stage, find <em>InteractiveObjects</em> that are under the mouse cursor, mouse-enabled and visible, and then find the one of those that is deepest in the display list. Gabriel&#8217;s solution doesn&#8217;t need to do any of this: it already has the <em>InteractiveObject</em> reference it wants to use at this point. The inaccuracy, on the other hand, stems from the fact that if the user doesn&#8217;t move their mouse, the reference won&#8217;t get updated. What this means is that if the <em>InteractiveObjects</em> on Stage have moved (in relation to the mouse cursor,) or been added to or removed from the display list while the cursor has stayed put, the reference will not be up to date, and probably incorrect.
</p>
<p>
As you&#8217;ve probably deduced from the last paragraph, there are upsides and downsides to both of these approaches, and I at least would like to be able to choose which one to use, based on the context of what I happen to be doing at the moment. This is why I&#8217;ve added this exact feature into the code in the form of a property the value of which you can set at will:</p>
<pre class="prettyprint">
private var _mwSupport:ExternalMouseWheelSupport = ExternalMouseWheelSupport.getInstance(stage);

_mwSupport.dispatchingObjectDeterminationMethod = ExternalMouseWheelSupport.COPY_MOUSEMOVE_EVENTS;
// or
_mwSupport.dispatchingObjectDeterminationMethod = ExternalMouseWheelSupport.TRAVERSE_DISPLAY_LIST;
</pre>
</p>
<p>
You can test the differences between these two options with the <a href="/stuff/AS3ExternalMouseWheelSupport/demo/example.html">demo</a>.
</p>
<h3>Deployment and use</h3>
<p>
So like I wrote before, the process of deploying and initializing this solution has changed a bit from the last version. This is how you do it now.</p>
<ol>
<li><strong>Include the JavaScript file onto the page that embeds the Flash object(s)</strong></li>
<div class="codecolorer-container html4strict mac-classic codecolorer-customstyle" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><div class="html4strict codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">script</span> <span style="color: #000066;">type</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;text/javascript&quot;</span> <span style="color: #000066;">src</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;./extMouseWheel.js&quot;</span>&gt;&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">script</span>&gt;</span></div></div>
<p></p>
<li><strong>Make sure your embedded Flash objects have a parent <em>div</em> element</strong></li>
<div class="codecolorer-container html4strict mac-classic codecolorer-customstyle" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><div class="html4strict codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">div</span> <span style="color: #000066;">style</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;width:600px;height:600px;&quot;</span> <span style="color: #000066;">id</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;flashContainerDiv&quot;</span>&gt;</span><br />
&nbsp; <span style="color: #808080; font-style: italic;">&lt;!-- add Flash object's &lt;object&gt; and &lt;embed&gt; tags here --&gt;</span><br />
<span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">div</span>&gt;</span></div></div>
<p></p>
<li><strong>In your AS3 code, get a reference to the singleton instance of <em>ExternalMouseWheelSupport</em> in at least one place</strong></li>
<p>As you can see, the singleton instance accessor is not a property anymore, but a method, so that you can pass a reference to the Stage to it. This change is because of the removal of dependencies to Flex libraries, which could be used to access the Stage instance in the previous version.</p>
<pre class="prettyprint">
import org.hasseg.externalMouseWheel.ExternalMouseWheelSupport;
private var _mwSupport:ExternalMouseWheelSupport = ExternalMouseWheelSupport.getInstance(stage);
</pre>
<p>I generally do this in the <em>applicationComplete</em> event handler, but you can of course call it wherever you want, as long as you make sure the Stage reference you&#8217;re using is not <em>null</em> (an Error will be thrown if it is.)</p>
</ol>
<p>&#8230;and that&#8217;s it. :)
</p>
<h3>Downloads and demo</h3>
<ul>
<li><a href="/stuff/AS3ExternalMouseWheelSupport/demo/example.html">A Working example</a></li>
<li><a href="/stuff/AS3ExternalMouseWheelSupport/AS3ExternalMouseWheelSupport.zip">The sources (ZIP archive)</a></li>
<li><a href="/stuff/AS3ExternalMouseWheelSupport/asdoc-output/index.html">AsDoc-generated API documentation</a></li>
</ul>
<p>This code is licensed under the <a href="/stuff/license/MIT_License.txt">MIT License</a>.
</p>
<h3>Other info</h3>
<p>
I&#8217;ve tested this solution with the following browsers (sadly, Opera on the Mac isn&#8217;t supported since <em>ExternalInterface</em> doesn&#8217;t seem to work in the latest version:)</p>
<ul>
<li><strong>On OS X 10.5.2:</strong></li>
<ul>
<li>Safari 3.1.1</li>
<li>Firefox 3 beta 5</li>
<li>Camino 1.6</li>
<li>OmniWeb 5.7</li>
</ul>
<li><strong>On Windows XP SP2:</strong></li>
<ul>
<li>Internet Explorer 7.0</li>
<li>Firefox 2.0</li>
<li>Safari 3.1.1</li>
<li>Opera 9.27</li>
</ul>
</ul>
<p>If someone could please test this on the Mac OS version of Firefox 2 and the Windows versions of Firefox 3 beta and IE 6, I&#8217;d very much appreciate it.</p>
]]></content:encoded>
			<wfw:commentRss>http://hasseg.org/blog/post/138/os-x-mouse-wheel-support-for-actionscript-3-flash-applications-v2/feed/</wfw:commentRss>
		<slash:comments>75</slash:comments>
		</item>
		<item>
		<title>Collapsible Panel Component for Flex</title>
		<link>http://hasseg.org/blog/post/113/collapsible-panel-component-for-flex/</link>
		<comments>http://hasseg.org/blog/post/113/collapsible-panel-component-for-flex/#comments</comments>
		<pubDate>Fri, 04 Jan 2008 17:27:19 +0000</pubDate>
		<dc:creator>Ali Rantakari</dc:creator>
				<category><![CDATA[ActionScript 3]]></category>
		<category><![CDATA[Flex]]></category>
		<category><![CDATA[Programming]]></category>

		<guid isPermaLink="false">http://hasseg.org/blog/?p=113</guid>
		<description><![CDATA[Here&#8217;s an another post in the same vein as my previous one: this time, the component I&#8217;m sharing is a Panel subclass that allows for collapsing and expanding its contents. What this means is that the user can click on the header of the Panel to make it toggle between an open or closed state, [...]]]></description>
			<content:encoded><![CDATA[<p>Here&#8217;s an another post in the same vein as my previous one: this time, the component I&#8217;m sharing is a Panel subclass that allows for collapsing and expanding its contents. What this means is that the user can click on the header of the Panel to make it toggle between an open or closed state, with a smooth animation.</p>
<p><span id="more-113"></span></p>
<p>
I Tried to implement the component so that it&#8217;ll be easy to use in both MXML and ActionScript. In the demo app there is also an example on styling the CollapsiblePanel.
</p>
<ul>
<li>Demo: <a href="/stuff/CollapsiblePanel/CollapsiblePanelDemo.swf">CollapsiblePanelDemo.swf</a></li>
<li>Sources: <a href="/stuff/CollapsiblePanel/CollapsiblePanelSources.zip">CollapsiblePanelSources.zip</a></li>
</ul>
<p>
<i>CollapsiblePanelDemo.mxml:</i></p>
<div class="codecolorer-container xml mac-classic codecolorer-customstyle" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;height:300px;"><div class="xml codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;?xml</span> <span style="color: #000066;">version</span>=<span style="color: #ff0000;">&quot;1.0&quot;</span> <span style="color: #000066;">encoding</span>=<span style="color: #ff0000;">&quot;utf-8&quot;</span><span style="color: #000000; font-weight: bold;">?&gt;</span></span><br />
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;mx:Application</span> </span><br />
<span style="color: #009900;">&nbsp; &nbsp; <span style="color: #000066;">xmlns:mx</span>=<span style="color: #ff0000;">&quot;http://www.adobe.com/2006/mxml&quot;</span></span><br />
<span style="color: #009900;">&nbsp; &nbsp; <span style="color: #000066;">xmlns:hassegContainers</span>=<span style="color: #ff0000;">&quot;org.hasseg.containers.*&quot;</span></span><br />
<span style="color: #009900;">&nbsp; &nbsp; <span style="color: #000066;">width</span>=<span style="color: #ff0000;">&quot;100%&quot;</span> <span style="color: #000066;">height</span>=<span style="color: #ff0000;">&quot;100%&quot;</span></span><br />
<span style="color: #009900;">&nbsp; &nbsp; <span style="color: #000066;">layout</span>=<span style="color: #ff0000;">&quot;vertical&quot;</span></span><br />
<span style="color: #009900;">&nbsp; &nbsp; <span style="color: #000066;">creationComplete</span>=<span style="color: #ff0000;">&quot;ccHandler(event);&quot;</span></span><br />
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&gt;</span></span><br />
&nbsp; &nbsp; <br />
&nbsp; &nbsp; <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;mx:Style<span style="color: #000000; font-weight: bold;">&gt;</span></span></span><br />
&nbsp; &nbsp; &nbsp; &nbsp; .myCPStyle {<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; borderThicknessLeft: 0;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; borderThicknessTop: 0;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; borderThicknessBottom: 0;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; borderThicknessRight: 0;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; headerHeight: 20;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; dropShadowEnabled: false;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; headerColors: #d9d9d9, #ffffff;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; borderAlpha: 1;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; backgroundAlpha: 0;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; paddingTop: 4;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; paddingLeft: 4;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; paddingRight: 4;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; verticalGap: 4;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; openIcon: Embed(source=&quot;icons.swf&quot;, symbol=&quot;CollapsiblePanelOpenIcon&quot;);<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; closedIcon: Embed(source=&quot;icons.swf&quot;, symbol=&quot;CollapsiblePanelClosedIcon&quot;);<br />
&nbsp; &nbsp; &nbsp; &nbsp; }<br />
&nbsp; &nbsp; <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/mx:Style<span style="color: #000000; font-weight: bold;">&gt;</span></span></span><br />
&nbsp; &nbsp; <br />
&nbsp; &nbsp; <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;mx:Script<span style="color: #000000; font-weight: bold;">&gt;</span></span></span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #339933;">&lt;![CDATA[</span><br />
<span style="color: #339933;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><br />
<span style="color: #339933;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; import mx.events.*;</span><br />
<span style="color: #339933;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><br />
<span style="color: #339933;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; private function ccHandler(event:FlexEvent):void {</span><br />
<span style="color: #339933;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; /*</span><br />
<span style="color: #339933;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; * An example of programmatically adding a new CollapsiblePanel:</span><br />
<span style="color: #339933;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; */</span><br />
<span style="color: #339933;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; var newCP:CollapsiblePanel = new CollapsiblePanel(false); // closed by default</span><br />
<span style="color: #339933;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; newCP.title = &quot;This added via AS&quot;;</span><br />
<span style="color: #339933;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; newCP.styleName = &quot;myCPStyle&quot;;</span><br />
<span style="color: #339933;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; var bOne:Button = new Button();</span><br />
<span style="color: #339933;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; var bTwo:Button = new Button();</span><br />
<span style="color: #339933;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; bOne.label = &quot;button one&quot;</span><br />
<span style="color: #339933;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; bTwo.label = &quot;button two&quot;</span><br />
<span style="color: #339933;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; newCP.addChild(bOne);</span><br />
<span style="color: #339933;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; newCP.addChild(bTwo);</span><br />
<span style="color: #339933;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; var newLabel:Label = new Label();</span><br />
<span style="color: #339933;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; newLabel.text = &quot;Added via ActionScript:&quot;;</span><br />
<span style="color: #339933;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; this.addChild(newLabel);</span><br />
<span style="color: #339933;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; this.addChild(newCP);</span><br />
<span style="color: #339933;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; }</span><br />
<span style="color: #339933;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><br />
<span style="color: #339933;">&nbsp; &nbsp; &nbsp; &nbsp; ]]&gt;</span><br />
&nbsp; &nbsp; <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/mx:Script<span style="color: #000000; font-weight: bold;">&gt;</span></span></span><br />
&nbsp; &nbsp; <br />
&nbsp; &nbsp; <br />
&nbsp; &nbsp; <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;mx:HBox<span style="color: #000000; font-weight: bold;">&gt;</span></span></span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;mx:Box<span style="color: #000000; font-weight: bold;">&gt;</span></span></span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;mx:Label</span> <span style="color: #000066;">text</span>=<span style="color: #ff0000;">&quot;styled, open=false:&quot;</span> <span style="color: #000000; font-weight: bold;">/&gt;</span></span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;hassegContainers:CollapsiblePanel</span></span><br />
<span style="color: #009900;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000066;">title</span>=<span style="color: #ff0000;">&quot;This is the title&quot;</span></span><br />
<span style="color: #009900;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000066;">width</span>=<span style="color: #ff0000;">&quot;200&quot;</span></span><br />
<span style="color: #009900;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000066;">open</span>=<span style="color: #ff0000;">&quot;false&quot;</span></span><br />
<span style="color: #009900;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000066;">styleName</span>=<span style="color: #ff0000;">&quot;myCPStyle&quot;</span></span><br />
<span style="color: #009900;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">&gt;</span></span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;mx:Button</span> <span style="color: #000066;">label</span>=<span style="color: #ff0000;">&quot;hello&quot;</span> <span style="color: #000000; font-weight: bold;">/&gt;</span></span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;mx:Button</span> <span style="color: #000066;">label</span>=<span style="color: #ff0000;">&quot;hello again&quot;</span> <span style="color: #000000; font-weight: bold;">/&gt;</span></span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/hassegContainers:CollapsiblePanel<span style="color: #000000; font-weight: bold;">&gt;</span></span></span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/mx:Box<span style="color: #000000; font-weight: bold;">&gt;</span></span></span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;mx:Box<span style="color: #000000; font-weight: bold;">&gt;</span></span></span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;mx:Label</span> <span style="color: #000066;">text</span>=<span style="color: #ff0000;">&quot;styled, open=true:&quot;</span> <span style="color: #000000; font-weight: bold;">/&gt;</span></span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;hassegContainers:CollapsiblePanel</span></span><br />
<span style="color: #009900;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000066;">title</span>=<span style="color: #ff0000;">&quot;This is the title&quot;</span></span><br />
<span style="color: #009900;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000066;">width</span>=<span style="color: #ff0000;">&quot;200&quot;</span></span><br />
<span style="color: #009900;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000066;">open</span>=<span style="color: #ff0000;">&quot;true&quot;</span></span><br />
<span style="color: #009900;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000066;">styleName</span>=<span style="color: #ff0000;">&quot;myCPStyle&quot;</span></span><br />
<span style="color: #009900;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">&gt;</span></span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;mx:Button</span> <span style="color: #000066;">label</span>=<span style="color: #ff0000;">&quot;hello&quot;</span> <span style="color: #000000; font-weight: bold;">/&gt;</span></span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;mx:Button</span> <span style="color: #000066;">label</span>=<span style="color: #ff0000;">&quot;hello again&quot;</span> <span style="color: #000000; font-weight: bold;">/&gt;</span></span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/hassegContainers:CollapsiblePanel<span style="color: #000000; font-weight: bold;">&gt;</span></span></span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/mx:Box<span style="color: #000000; font-weight: bold;">&gt;</span></span></span><br />
&nbsp; &nbsp; <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/mx:HBox<span style="color: #000000; font-weight: bold;">&gt;</span></span></span><br />
&nbsp; &nbsp; <br />
&nbsp; &nbsp; <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;mx:HBox<span style="color: #000000; font-weight: bold;">&gt;</span></span></span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;mx:Box<span style="color: #000000; font-weight: bold;">&gt;</span></span></span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;mx:Label</span> <span style="color: #000066;">text</span>=<span style="color: #ff0000;">&quot;styled, open attribute not set:&quot;</span> <span style="color: #000000; font-weight: bold;">/&gt;</span></span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;hassegContainers:CollapsiblePanel</span></span><br />
<span style="color: #009900;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000066;">title</span>=<span style="color: #ff0000;">&quot;This is the title&quot;</span></span><br />
<span style="color: #009900;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000066;">width</span>=<span style="color: #ff0000;">&quot;200&quot;</span></span><br />
<span style="color: #009900;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000066;">styleName</span>=<span style="color: #ff0000;">&quot;myCPStyle&quot;</span></span><br />
<span style="color: #009900;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">&gt;</span></span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;mx:Button</span> <span style="color: #000066;">label</span>=<span style="color: #ff0000;">&quot;hello&quot;</span> <span style="color: #000000; font-weight: bold;">/&gt;</span></span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;mx:Button</span> <span style="color: #000066;">label</span>=<span style="color: #ff0000;">&quot;hello again&quot;</span> <span style="color: #000000; font-weight: bold;">/&gt;</span></span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/hassegContainers:CollapsiblePanel<span style="color: #000000; font-weight: bold;">&gt;</span></span></span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/mx:Box<span style="color: #000000; font-weight: bold;">&gt;</span></span></span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;mx:Box<span style="color: #000000; font-weight: bold;">&gt;</span></span></span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;mx:Label</span> <span style="color: #000066;">text</span>=<span style="color: #ff0000;">&quot;not styled, open=false:&quot;</span> <span style="color: #000000; font-weight: bold;">/&gt;</span></span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;hassegContainers:CollapsiblePanel</span></span><br />
<span style="color: #009900;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000066;">title</span>=<span style="color: #ff0000;">&quot;This is the title&quot;</span></span><br />
<span style="color: #009900;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000066;">width</span>=<span style="color: #ff0000;">&quot;200&quot;</span></span><br />
<span style="color: #009900;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000066;">open</span>=<span style="color: #ff0000;">&quot;false&quot;</span></span><br />
<span style="color: #009900;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">&gt;</span></span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;mx:Button</span> <span style="color: #000066;">label</span>=<span style="color: #ff0000;">&quot;hello&quot;</span> <span style="color: #000000; font-weight: bold;">/&gt;</span></span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;mx:Button</span> <span style="color: #000066;">label</span>=<span style="color: #ff0000;">&quot;hello again&quot;</span> <span style="color: #000000; font-weight: bold;">/&gt;</span></span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/hassegContainers:CollapsiblePanel<span style="color: #000000; font-weight: bold;">&gt;</span></span></span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/mx:Box<span style="color: #000000; font-weight: bold;">&gt;</span></span></span><br />
&nbsp; &nbsp; <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/mx:HBox<span style="color: #000000; font-weight: bold;">&gt;</span></span></span><br />
&nbsp; &nbsp; <br />
&nbsp; &nbsp; <br />
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/mx:Application<span style="color: #000000; font-weight: bold;">&gt;</span></span></span></div></div>
</p>
<p>
<i>CollapsiblePanel.as:</i></p>
<div class="codecolorer-container actionscript mac-classic codecolorer-customstyle" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;height:300px;"><div class="actionscript codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color: #808080; font-style: italic;">/*<br />
<br />
The MIT License<br />
<br />
Copyright (c) 2007-2008 Ali Rantakari of hasseg.org<br />
<br />
Permission is hereby granted, free of charge, to any person obtaining a copy<br />
of this software and associated documentation files (the &quot;Software&quot;), to deal<br />
in the Software without restriction, including without limitation the rights<br />
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell<br />
copies of the Software, and to permit persons to whom the Software is<br />
furnished to do so, subject to the following conditions:<br />
<br />
The above copyright notice and this permission notice shall be included in<br />
all copies or substantial portions of the Software.<br />
<br />
THE SOFTWARE IS PROVIDED &quot;AS IS&quot;, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR<br />
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,<br />
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE<br />
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER<br />
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,<br />
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN<br />
THE SOFTWARE.<br />
<br />
*/</span><br />
<br />
package org.<span style="color: #006600;">hasseg</span>.<span style="color: #006600;">containers</span> <span style="color: #66cc66;">&#123;</span><br />
&nbsp; &nbsp; <br />
&nbsp; &nbsp; <span style="color: #0066CC;">import</span> flash.<span style="color: #006600;">events</span>.<span style="color: #66cc66;">*</span>;<br />
&nbsp; &nbsp; <span style="color: #0066CC;">import</span> mx.<span style="color: #006600;">effects</span>.<span style="color: #006600;">AnimateProperty</span>;<br />
&nbsp; &nbsp; <span style="color: #0066CC;">import</span> mx.<span style="color: #006600;">events</span>.<span style="color: #66cc66;">*</span>;<br />
&nbsp; &nbsp; <span style="color: #0066CC;">import</span> mx.<span style="color: #006600;">containers</span>.<span style="color: #006600;">Panel</span>;<br />
&nbsp; &nbsp; <span style="color: #0066CC;">import</span> mx.<span style="color: #006600;">core</span>.<span style="color: #006600;">ScrollPolicy</span>;<br />
&nbsp; &nbsp; <br />
&nbsp; &nbsp; <br />
&nbsp; &nbsp; <span style="color: #808080; font-style: italic;">/**<br />
&nbsp; &nbsp; * The icon designating a &quot;closed&quot; state<br />
&nbsp; &nbsp; */</span><br />
&nbsp; &nbsp; <span style="color: #66cc66;">&#91;</span>Style<span style="color: #66cc66;">&#40;</span><span style="color: #0066CC;">name</span>=<span style="color: #ff0000;">&quot;closedIcon&quot;</span>, property=<span style="color: #ff0000;">&quot;closedIcon&quot;</span>, <span style="color: #0066CC;">type</span>=<span style="color: #ff0000;">&quot;Object&quot;</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#93;</span><br />
&nbsp; &nbsp; <br />
&nbsp; &nbsp; <span style="color: #808080; font-style: italic;">/**<br />
&nbsp; &nbsp; * The icon designating an &quot;open&quot; state<br />
&nbsp; &nbsp; */</span><br />
&nbsp; &nbsp; <span style="color: #66cc66;">&#91;</span>Style<span style="color: #66cc66;">&#40;</span><span style="color: #0066CC;">name</span>=<span style="color: #ff0000;">&quot;openIcon&quot;</span>, property=<span style="color: #ff0000;">&quot;openIcon&quot;</span>, <span style="color: #0066CC;">type</span>=<span style="color: #ff0000;">&quot;Object&quot;</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#93;</span><br />
&nbsp; &nbsp; <br />
&nbsp; &nbsp; <span style="color: #808080; font-style: italic;">/**<br />
&nbsp; &nbsp; * This is a Panel that can be collapsed and expanded by clicking on the header.<br />
&nbsp; &nbsp; * <br />
&nbsp; &nbsp; * @author Ali Rantakari<br />
&nbsp; &nbsp; */</span><br />
&nbsp; &nbsp; <span style="color: #0066CC;">public</span> <span style="color: #000000; font-weight: bold;">class</span> CollapsiblePanel <span style="color: #0066CC;">extends</span> Panel <span style="color: #66cc66;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0066CC;">private</span> <span style="color: #000000; font-weight: bold;">var</span> _creationComplete:<span style="color: #0066CC;">Boolean</span> = <span style="color: #000000; font-weight: bold;">false</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0066CC;">private</span> <span style="color: #000000; font-weight: bold;">var</span> _open:<span style="color: #0066CC;">Boolean</span> = <span style="color: #000000; font-weight: bold;">true</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0066CC;">private</span> <span style="color: #000000; font-weight: bold;">var</span> _openAnim:AnimateProperty;<br />
&nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #808080; font-style: italic;">/**<br />
&nbsp; &nbsp; &nbsp; &nbsp; * Constructor<br />
&nbsp; &nbsp; &nbsp; &nbsp; * <br />
&nbsp; &nbsp; &nbsp; &nbsp; */</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0066CC;">public</span> <span style="color: #000000; font-weight: bold;">function</span> CollapsiblePanel<span style="color: #66cc66;">&#40;</span>aOpen:<span style="color: #0066CC;">Boolean</span> = <span style="color: #000000; font-weight: bold;">true</span><span style="color: #66cc66;">&#41;</span>:<span style="color: #0066CC;">void</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #66cc66;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0066CC;">super</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; open = aOpen;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0066CC;">this</span>.<span style="color: #006600;">addEventListener</span><span style="color: #66cc66;">&#40;</span>FlexEvent.<span style="color: #006600;">CREATION_COMPLETE</span>, creationCompleteHandler<span style="color: #66cc66;">&#41;</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #66cc66;">&#125;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #808080; font-style: italic;">// BEGIN: event handlers&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; ------------------------------------------------------------</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0066CC;">private</span> <span style="color: #000000; font-weight: bold;">function</span> creationCompleteHandler<span style="color: #66cc66;">&#40;</span>event:FlexEvent<span style="color: #66cc66;">&#41;</span>:<span style="color: #0066CC;">void</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #66cc66;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0066CC;">this</span>.<span style="color: #006600;">horizontalScrollPolicy</span> = ScrollPolicy.<span style="color: #006600;">OFF</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0066CC;">this</span>.<span style="color: #006600;">verticalScrollPolicy</span> = ScrollPolicy.<span style="color: #006600;">OFF</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; _openAnim = <span style="color: #000000; font-weight: bold;">new</span> AnimateProperty<span style="color: #66cc66;">&#40;</span><span style="color: #0066CC;">this</span><span style="color: #66cc66;">&#41;</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; _openAnim.<span style="color: #0066CC;">duration</span> = <span style="color: #cc66cc;">300</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; _openAnim.<span style="color: #006600;">property</span> = <span style="color: #ff0000;">&quot;height&quot;</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; titleBar.<span style="color: #006600;">addEventListener</span><span style="color: #66cc66;">&#40;</span>MouseEvent.<span style="color: #006600;">CLICK</span>, headerClickHandler<span style="color: #66cc66;">&#41;</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; _creationComplete = <span style="color: #000000; font-weight: bold;">true</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #66cc66;">&#125;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0066CC;">private</span> <span style="color: #000000; font-weight: bold;">function</span> headerClickHandler<span style="color: #66cc66;">&#40;</span>event:MouseEvent<span style="color: #66cc66;">&#41;</span>:<span style="color: #0066CC;">void</span> <span style="color: #66cc66;">&#123;</span> toggleOpen<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>; <span style="color: #66cc66;">&#125;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0066CC;">private</span> <span style="color: #000000; font-weight: bold;">function</span> callUpdateOpenOnCreationComplete<span style="color: #66cc66;">&#40;</span>event:FlexEvent<span style="color: #66cc66;">&#41;</span>:<span style="color: #0066CC;">void</span> <span style="color: #66cc66;">&#123;</span> updateOpen<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>; <span style="color: #66cc66;">&#125;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #808080; font-style: italic;">// --end--: event handlers&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #808080; font-style: italic;">// BEGIN: private methods &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; ------------------------------------------------------------</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #808080; font-style: italic;">// sets the height of the component without animation, based</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #808080; font-style: italic;">// on the _open variable</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0066CC;">private</span> <span style="color: #000000; font-weight: bold;">function</span> updateOpen<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>:<span style="color: #0066CC;">void</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #66cc66;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #b1b100;">if</span> <span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">!</span>_open<span style="color: #66cc66;">&#41;</span> <span style="color: #0066CC;">height</span> = closedHeight;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #b1b100;">else</span> <span style="color: #0066CC;">height</span> = openHeight;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; setTitleIcon<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #66cc66;">&#125;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #808080; font-style: italic;">// the height that the component should be when open</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0066CC;">private</span> <span style="color: #000000; font-weight: bold;">function</span> <span style="color: #0066CC;">get</span> openHeight<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>:<span style="color: #0066CC;">Number</span> <span style="color: #66cc66;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #b1b100;">return</span> measuredHeight;<br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #66cc66;">&#125;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #808080; font-style: italic;">// the height that the component should be when closed</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0066CC;">private</span> <span style="color: #000000; font-weight: bold;">function</span> <span style="color: #0066CC;">get</span> closedHeight<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>:<span style="color: #0066CC;">Number</span> <span style="color: #66cc66;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">var</span> hh:<span style="color: #0066CC;">Number</span> = <span style="color: #0066CC;">getStyle</span><span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">&quot;headerHeight&quot;</span><span style="color: #66cc66;">&#41;</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #b1b100;">if</span> <span style="color: #66cc66;">&#40;</span>hh <span style="color: #66cc66;">&lt;</span>= <span style="color: #cc66cc;">0</span> <span style="color: #66cc66;">||</span> <span style="color: #0066CC;">isNaN</span><span style="color: #66cc66;">&#40;</span>hh<span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span> hh = titleBar.<span style="color: #0066CC;">height</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #b1b100;">return</span> hh;<br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #66cc66;">&#125;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #808080; font-style: italic;">// sets the correct title icon</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0066CC;">private</span> <span style="color: #000000; font-weight: bold;">function</span> setTitleIcon<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>:<span style="color: #0066CC;">void</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #66cc66;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #b1b100;">if</span> <span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">!</span>_open<span style="color: #66cc66;">&#41;</span> <span style="color: #0066CC;">this</span>.<span style="color: #006600;">titleIcon</span> = <span style="color: #0066CC;">getStyle</span><span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">&quot;closedIcon&quot;</span><span style="color: #66cc66;">&#41;</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #b1b100;">else</span> <span style="color: #0066CC;">this</span>.<span style="color: #006600;">titleIcon</span> = <span style="color: #0066CC;">getStyle</span><span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">&quot;openIcon&quot;</span><span style="color: #66cc66;">&#41;</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #66cc66;">&#125;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #808080; font-style: italic;">// --end--: private methods &nbsp; &nbsp; &nbsp; &nbsp; - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #808080; font-style: italic;">// BEGIN: public methods&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; ------------------------------------------------------------</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #808080; font-style: italic;">/**<br />
&nbsp; &nbsp; &nbsp; &nbsp; * Collapses / expands this block (with animation)<br />
&nbsp; &nbsp; &nbsp; &nbsp; */</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0066CC;">public</span> <span style="color: #000000; font-weight: bold;">function</span> toggleOpen<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>:<span style="color: #0066CC;">void</span> <br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #66cc66;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #b1b100;">if</span> <span style="color: #66cc66;">&#40;</span>_creationComplete <span style="color: #66cc66;">&amp;&amp;</span> <span style="color: #66cc66;">!</span>_openAnim.<span style="color: #006600;">isPlaying</span><span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; _openAnim.<span style="color: #006600;">fromValue</span> = _openAnim.<span style="color: #0066CC;">target</span>.<span style="color: #0066CC;">height</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #b1b100;">if</span> <span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">!</span>_open<span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; _openAnim.<span style="color: #006600;">toValue</span> = openHeight;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; _open = <span style="color: #000000; font-weight: bold;">true</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; dispatchEvent<span style="color: #66cc66;">&#40;</span><span style="color: #000000; font-weight: bold;">new</span> Event<span style="color: #66cc66;">&#40;</span>Event.<span style="color: #006600;">OPEN</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #66cc66;">&#125;</span><span style="color: #b1b100;">else</span><span style="color: #66cc66;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; _openAnim.<span style="color: #006600;">toValue</span> = _openAnim.<span style="color: #0066CC;">target</span>.<span style="color: #006600;">closedHeight</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; _open = <span style="color: #000000; font-weight: bold;">false</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; dispatchEvent<span style="color: #66cc66;">&#40;</span><span style="color: #000000; font-weight: bold;">new</span> Event<span style="color: #66cc66;">&#40;</span>Event.<span style="color: #0066CC;">CLOSE</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #66cc66;">&#125;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; setTitleIcon<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; _openAnim.<span style="color: #0066CC;">play</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #66cc66;">&#125;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #66cc66;">&#125;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #808080; font-style: italic;">/**<br />
&nbsp; &nbsp; &nbsp; &nbsp; * Whether the block is in a expanded (open) state or not<br />
&nbsp; &nbsp; &nbsp; &nbsp; */</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0066CC;">public</span> <span style="color: #000000; font-weight: bold;">function</span> <span style="color: #0066CC;">get</span> open<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>:<span style="color: #0066CC;">Boolean</span> <span style="color: #66cc66;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #b1b100;">return</span> _open;<br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #66cc66;">&#125;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #808080; font-style: italic;">/**<br />
&nbsp; &nbsp; &nbsp; &nbsp; * @private<br />
&nbsp; &nbsp; &nbsp; &nbsp; */</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0066CC;">public</span> <span style="color: #000000; font-weight: bold;">function</span> <span style="color: #0066CC;">set</span> open<span style="color: #66cc66;">&#40;</span>aValue:<span style="color: #0066CC;">Boolean</span><span style="color: #66cc66;">&#41;</span>:<span style="color: #0066CC;">void</span> <span style="color: #66cc66;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; _open = aValue;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #b1b100;">if</span> <span style="color: #66cc66;">&#40;</span>_creationComplete<span style="color: #66cc66;">&#41;</span> updateOpen<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #b1b100;">else</span> <span style="color: #0066CC;">this</span>.<span style="color: #006600;">addEventListener</span><span style="color: #66cc66;">&#40;</span>FlexEvent.<span style="color: #006600;">CREATION_COMPLETE</span>, callUpdateOpenOnCreationComplete, <span style="color: #000000; font-weight: bold;">false</span>, <span style="color: #cc66cc;">0</span>, <span style="color: #000000; font-weight: bold;">true</span><span style="color: #66cc66;">&#41;</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #66cc66;">&#125;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #808080; font-style: italic;">/**<br />
&nbsp; &nbsp; &nbsp; &nbsp; * @private<br />
&nbsp; &nbsp; &nbsp; &nbsp; */</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; override <span style="color: #0066CC;">public</span> <span style="color: #000000; font-weight: bold;">function</span> invalidateSize<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>:<span style="color: #0066CC;">void</span> <span style="color: #66cc66;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0066CC;">super</span>.<span style="color: #006600;">invalidateSize</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #b1b100;">if</span> <span style="color: #66cc66;">&#40;</span>_creationComplete<span style="color: #66cc66;">&#41;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #b1b100;">if</span> <span style="color: #66cc66;">&#40;</span>_open <span style="color: #66cc66;">&amp;&amp;</span> <span style="color: #66cc66;">!</span>_openAnim.<span style="color: #006600;">isPlaying</span><span style="color: #66cc66;">&#41;</span> <span style="color: #0066CC;">this</span>.<span style="color: #0066CC;">height</span> = openHeight;<br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #66cc66;">&#125;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #808080; font-style: italic;">// --end--: public methods&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; <span style="color: #66cc66;">&#125;</span><br />
<br />
<span style="color: #66cc66;">&#125;</span></div></div></p>
]]></content:encoded>
			<wfw:commentRss>http://hasseg.org/blog/post/113/collapsible-panel-component-for-flex/feed/</wfw:commentRss>
		<slash:comments>22</slash:comments>
		</item>
		<item>
		<title>Vertical TabNavigator Component for Flex</title>
		<link>http://hasseg.org/blog/post/112/vertical-tabnavigator-component-for-flex/</link>
		<comments>http://hasseg.org/blog/post/112/vertical-tabnavigator-component-for-flex/#comments</comments>
		<pubDate>Thu, 03 Jan 2008 11:52:21 +0000</pubDate>
		<dc:creator>Ali Rantakari</dc:creator>
				<category><![CDATA[ActionScript 3]]></category>
		<category><![CDATA[Flex]]></category>
		<category><![CDATA[Programming]]></category>

		<guid isPermaLink="false">http://hasseg.org/blog/?p=112</guid>
		<description><![CDATA[I Some time ago ran into a situation with a Flex app I was working on where I needed to use a TabNavigator component, but have its TabBar situated on the left or right side of the ViewStack (instead of on the top, where it is in the default TabNavigator.) I Could not find any [...]]]></description>
			<content:encoded><![CDATA[<p>I Some time ago ran into a situation with a Flex app I was working on where I needed to use a TabNavigator component, but have its TabBar situated on the left or right side of the ViewStack (instead of on the top, where it is in the default TabNavigator.) I Could not find any workable solutions online (the ones I did find could pretty much be described as ugly hacks,) so I made my own by extending the default TabNavigator. I Submitted this component to the <a href="http://code.google.com/p/flexlib/">flexlib project</a>, but since it has pretty much been ignored in the discussion group, I thought I&#8217;d post it here to make it available to the general public.</p>
<p><i><b>Update (same day as orig. post):</b> Added simple demo and example code on how to use the component. Added comment about using embedded fonts.</i></p>
<p><span id="more-112"></span></p>
<p>The way this works is basically by taking the TabBar component (a child of the whole TabNavigator component,) rotating it to make it vertical, positioning it to either side of the ViewStack, and making several adjustments to the component&#8217;s size to accommodate the new location of the TabBar. One thing to remember when using this is that <u>you need to embed the font you want to use for the TabBar labels with your app</u>, since rotated text doesn&#8217;t work in Flash player with system fonts. Also make sure that you&#8217;re embedding a bold version of the font, since text in the TabBar buttons is bold by default.</p>
<p>I Used Flex 2.0.1 to do this. Below you can look at the demo and see how it looks, download the zipped source, or just look at the code:</p>
<ul>
<li>Demo: <a href="/stuff/VerticalTabNavigator/VerticalTabNavigatorDemo.swf">VerticalTabNavigatorDemo.swf</a></li>
<li>Sources: <a href="/stuff/VerticalTabNavigator/VerticalTabNavigator.zip">VerticalTabNavigator.zip</a></li>
</ul>
<p>
<i>VerticalTabNavigatorDemo.mxml:</i></p>
<div class="codecolorer-container xml mac-classic codecolorer-customstyle" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><div class="xml codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;?xml</span> <span style="color: #000066;">version</span>=<span style="color: #ff0000;">&quot;1.0&quot;</span> <span style="color: #000066;">encoding</span>=<span style="color: #ff0000;">&quot;utf-8&quot;</span><span style="color: #000000; font-weight: bold;">?&gt;</span></span><br />
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;mx:Application</span> </span><br />
<span style="color: #009900;">&nbsp; &nbsp; <span style="color: #000066;">xmlns:mx</span>=<span style="color: #ff0000;">&quot;http://www.adobe.com/2006/mxml&quot;</span></span><br />
<span style="color: #009900;">&nbsp; &nbsp; <span style="color: #000066;">xmlns:hassegContainers</span>=<span style="color: #ff0000;">&quot;org.hasseg.containers.*&quot;</span></span><br />
<span style="color: #009900;">&nbsp; &nbsp; <span style="color: #000066;">width</span>=<span style="color: #ff0000;">&quot;100%&quot;</span> <span style="color: #000066;">height</span>=<span style="color: #ff0000;">&quot;100%&quot;</span></span><br />
<span style="color: #009900;">&nbsp; &nbsp; <span style="color: #000066;">layout</span>=<span style="color: #ff0000;">&quot;horizontal&quot;</span></span><br />
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&gt;</span></span><br />
&nbsp; &nbsp; <br />
&nbsp; &nbsp; <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;mx:Style<span style="color: #000000; font-weight: bold;">&gt;</span></span></span><br />
&nbsp; &nbsp; &nbsp; &nbsp; /* embedded font */<br />
&nbsp; &nbsp; &nbsp; &nbsp; @font-face {<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; src:url(&quot;Charrington.ttf&quot;);<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; fontFamily: myFont;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; flashType: true;<br />
&nbsp; &nbsp; &nbsp; &nbsp; }<br />
&nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; /* embedded font, bold */<br />
&nbsp; &nbsp; &nbsp; &nbsp; @font-face {<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; src:url(&quot;CharringtonBold.ttf&quot;);<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; fontFamily: myFont;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; flashType: true;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; fontWeight: bold;<br />
&nbsp; &nbsp; &nbsp; &nbsp; }<br />
&nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; /* Must use embedded font (bold version) for<br />
&nbsp; &nbsp; &nbsp; &nbsp; * &nbsp;VerticalTabNavigator's TabBar because rotating<br />
&nbsp; &nbsp; &nbsp; &nbsp; * &nbsp;text in the flash player requires that the fonts<br />
&nbsp; &nbsp; &nbsp; &nbsp; * &nbsp;be embedded and not system fonts. Using global<br />
&nbsp; &nbsp; &nbsp; &nbsp; * &nbsp;selector here for convenience.<br />
&nbsp; &nbsp; &nbsp; &nbsp; */<br />
&nbsp; &nbsp; &nbsp; &nbsp; global {<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; fontFamily: myFont;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; fontSize: 13pt;<br />
&nbsp; &nbsp; &nbsp; &nbsp; }<br />
&nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/mx:Style<span style="color: #000000; font-weight: bold;">&gt;</span></span></span><br />
&nbsp; &nbsp; <br />
&nbsp; &nbsp; <br />
&nbsp; &nbsp; <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;hassegContainers:VerticalTabNavigator</span></span><br />
<span style="color: #009900;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000066;">width</span>=<span style="color: #ff0000;">&quot;200&quot;</span> <span style="color: #000066;">height</span>=<span style="color: #ff0000;">&quot;400&quot;</span></span><br />
<span style="color: #009900;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000066;">tabBarLocation</span>=<span style="color: #ff0000;">&quot;left&quot;</span></span><br />
<span style="color: #009900;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000066;">verticalAlign</span>=<span style="color: #ff0000;">&quot;top&quot;</span></span><br />
<span style="color: #009900;">&nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">&gt;</span></span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;mx:Box</span> <span style="color: #000066;">label</span>=<span style="color: #ff0000;">&quot;one&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span></span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;mx:Label</span> <span style="color: #000066;">text</span>=<span style="color: #ff0000;">&quot;area one&quot;</span> <span style="color: #000000; font-weight: bold;">/&gt;</span></span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/mx:Box<span style="color: #000000; font-weight: bold;">&gt;</span></span></span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;mx:Box</span> <span style="color: #000066;">label</span>=<span style="color: #ff0000;">&quot;two&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span></span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;mx:Label</span> <span style="color: #000066;">text</span>=<span style="color: #ff0000;">&quot;area two&quot;</span> <span style="color: #000000; font-weight: bold;">/&gt;</span></span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/mx:Box<span style="color: #000000; font-weight: bold;">&gt;</span></span></span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;mx:Box</span> <span style="color: #000066;">label</span>=<span style="color: #ff0000;">&quot;three&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span></span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;mx:Label</span> <span style="color: #000066;">text</span>=<span style="color: #ff0000;">&quot;area three&quot;</span> <span style="color: #000000; font-weight: bold;">/&gt;</span></span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/mx:Box<span style="color: #000000; font-weight: bold;">&gt;</span></span></span><br />
&nbsp; &nbsp; <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/hassegContainers:VerticalTabNavigator<span style="color: #000000; font-weight: bold;">&gt;</span></span></span><br />
&nbsp; &nbsp; <br />
&nbsp; &nbsp; <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;mx:Spacer</span> <span style="color: #000066;">width</span>=<span style="color: #ff0000;">&quot;50&quot;</span> <span style="color: #000000; font-weight: bold;">/&gt;</span></span><br />
&nbsp; &nbsp; <br />
&nbsp; &nbsp; <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;hassegContainers:VerticalTabNavigator</span></span><br />
<span style="color: #009900;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000066;">width</span>=<span style="color: #ff0000;">&quot;200&quot;</span> <span style="color: #000066;">height</span>=<span style="color: #ff0000;">&quot;400&quot;</span></span><br />
<span style="color: #009900;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000066;">tabBarLocation</span>=<span style="color: #ff0000;">&quot;right&quot;</span></span><br />
<span style="color: #009900;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000066;">verticalAlign</span>=<span style="color: #ff0000;">&quot;middle&quot;</span></span><br />
<span style="color: #009900;">&nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">&gt;</span></span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;mx:Box</span> <span style="color: #000066;">label</span>=<span style="color: #ff0000;">&quot;one&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span></span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;mx:Label</span> <span style="color: #000066;">text</span>=<span style="color: #ff0000;">&quot;area one&quot;</span> <span style="color: #000000; font-weight: bold;">/&gt;</span></span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/mx:Box<span style="color: #000000; font-weight: bold;">&gt;</span></span></span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;mx:Box</span> <span style="color: #000066;">label</span>=<span style="color: #ff0000;">&quot;two&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span></span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;mx:Label</span> <span style="color: #000066;">text</span>=<span style="color: #ff0000;">&quot;area two&quot;</span> <span style="color: #000000; font-weight: bold;">/&gt;</span></span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/mx:Box<span style="color: #000000; font-weight: bold;">&gt;</span></span></span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;mx:Box</span> <span style="color: #000066;">label</span>=<span style="color: #ff0000;">&quot;three&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span></span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;mx:Label</span> <span style="color: #000066;">text</span>=<span style="color: #ff0000;">&quot;area three&quot;</span> <span style="color: #000000; font-weight: bold;">/&gt;</span></span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/mx:Box<span style="color: #000000; font-weight: bold;">&gt;</span></span></span><br />
&nbsp; &nbsp; <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/hassegContainers:VerticalTabNavigator<span style="color: #000000; font-weight: bold;">&gt;</span></span></span><br />
&nbsp; &nbsp; <br />
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/mx:Application<span style="color: #000000; font-weight: bold;">&gt;</span></span></span></div></div>
</p>
<p>
<i>VerticalTabNavigator.as:</i></p>
<div class="codecolorer-container actionscript mac-classic codecolorer-customstyle" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;height:300px;"><div class="actionscript codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color: #808080; font-style: italic;">/*<br />
<br />
The MIT License<br />
<br />
Copyright (c) 2007-2008 Ali Rantakari<br />
<br />
Permission is hereby granted, free of charge, to any person obtaining a copy<br />
of this software and associated documentation files (the &quot;Software&quot;), to deal<br />
in the Software without restriction, including without limitation the rights<br />
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell<br />
copies of the Software, and to permit persons to whom the Software is<br />
furnished to do so, subject to the following conditions:<br />
<br />
The above copyright notice and this permission notice shall be included in<br />
all copies or substantial portions of the Software.<br />
<br />
THE SOFTWARE IS PROVIDED &quot;AS IS&quot;, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR<br />
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,<br />
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE<br />
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER<br />
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,<br />
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN<br />
THE SOFTWARE.<br />
<br />
*/</span><br />
<br />
package org.<span style="color: #006600;">hasseg</span>.<span style="color: #006600;">containers</span> <span style="color: #66cc66;">&#123;</span><br />
&nbsp; &nbsp; <br />
&nbsp; &nbsp; <span style="color: #0066CC;">import</span> flash.<span style="color: #006600;">display</span>.<span style="color: #006600;">DisplayObject</span>;<br />
&nbsp; &nbsp; <span style="color: #0066CC;">import</span> mx.<span style="color: #006600;">containers</span>.<span style="color: #006600;">TabNavigator</span>;<br />
&nbsp; &nbsp; <span style="color: #0066CC;">import</span> mx.<span style="color: #006600;">core</span>.<span style="color: #006600;">EdgeMetrics</span>;<br />
&nbsp; &nbsp; <span style="color: #0066CC;">import</span> mx.<span style="color: #006600;">core</span>.<span style="color: #006600;">IFlexDisplayObject</span>;<br />
&nbsp; &nbsp; <span style="color: #0066CC;">import</span> mx.<span style="color: #006600;">core</span>.<span style="color: #006600;">IInvalidating</span>;<br />
&nbsp; &nbsp; <span style="color: #0066CC;">import</span> mx.<span style="color: #006600;">core</span>.<span style="color: #006600;">mx_internal</span>;<br />
&nbsp; &nbsp; <span style="color: #0066CC;">import</span> mx.<span style="color: #006600;">skins</span>.<span style="color: #006600;">ProgrammaticSkin</span>;<br />
&nbsp; &nbsp; <br />
&nbsp; &nbsp; use namespace mx_internal;<br />
&nbsp; &nbsp; <br />
&nbsp; &nbsp; <span style="color: #808080; font-style: italic;">/**<br />
&nbsp; &nbsp; * &nbsp;Vertical positioning of tabs at the side of this VerticalTabNavigator container.<br />
&nbsp; &nbsp; * &nbsp;The possible values are &lt;code&gt;&quot;top&quot;&lt;/code&gt;, &lt;code&gt;&quot;middle&quot;&lt;/code&gt;,<br />
&nbsp; &nbsp; * &nbsp;and &lt;code&gt;&quot;bottom&quot;&lt;/code&gt;.<br />
&nbsp; &nbsp; * &nbsp;The default value is &lt;code&gt;&quot;top&quot;&lt;/code&gt;.<br />
&nbsp; &nbsp; *<br />
&nbsp; &nbsp; * &nbsp;&lt;p&gt;If the value is &lt;code&gt;&quot;top&quot;&lt;/code&gt;, the top edge of the tab bar<br />
&nbsp; &nbsp; * &nbsp;is aligned with the top edge of the VerticalTabNavigator container.<br />
&nbsp; &nbsp; * &nbsp;If the value is &lt;code&gt;&quot;bottom&quot;&lt;/code&gt;, the bottom edge of the tab bar<br />
&nbsp; &nbsp; * &nbsp;is aligned with the bottom edge of the VerticalTabNavigator container.<br />
&nbsp; &nbsp; * &nbsp;If the value is &lt;code&gt;&quot;middle&quot;&lt;/code&gt;, the tabs are centered on the side<br />
&nbsp; &nbsp; * &nbsp;of the VerticalTabNavigator container.&lt;/p&gt;<br />
&nbsp; &nbsp; *<br />
&nbsp; &nbsp; * &nbsp;&lt;p&gt;To see a difference between the alignments,<br />
&nbsp; &nbsp; * &nbsp;the total width of all the tabs must be less than<br />
&nbsp; &nbsp; * &nbsp;the height of the VerticalTabNavigator container.&lt;/p&gt;<br />
&nbsp; &nbsp; */</span><br />
&nbsp; &nbsp; <span style="color: #66cc66;">&#91;</span>Style<span style="color: #66cc66;">&#40;</span><span style="color: #0066CC;">name</span>=<span style="color: #ff0000;">&quot;verticalAlign&quot;</span>, <span style="color: #0066CC;">type</span>=<span style="color: #ff0000;">&quot;String&quot;</span>, enumeration=<span style="color: #ff0000;">&quot;top,middle,bottom&quot;</span>, inherit=<span style="color: #ff0000;">&quot;no&quot;</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#93;</span><br />
&nbsp; &nbsp; <br />
&nbsp; &nbsp; <span style="color: #808080; font-style: italic;">/**<br />
&nbsp; &nbsp; * A TabNavigator that positions the tab bar to either side<br />
&nbsp; &nbsp; * (left or right) of the component instead of at the top.<br />
&nbsp; &nbsp; * <br />
&nbsp; &nbsp; * &lt;p&gt;The value of the &lt;code&gt;tabBarLocation&lt;/code&gt; property determines<br />
&nbsp; &nbsp; * whether to position the tab bar to the left or the right side.&lt;/p&gt;<br />
&nbsp; &nbsp; * <br />
&nbsp; &nbsp; * &lt;p&gt;The &lt;code&gt;verticalAlign&lt;/code&gt; style property can be used to <br />
&nbsp; &nbsp; * align the tab bar with the top or the bottom of the component, or to<br />
&nbsp; &nbsp; * vertically center it.&lt;/p&gt;<br />
&nbsp; &nbsp; * <br />
&nbsp; &nbsp; * @see mx.containers.TabNavigator<br />
&nbsp; &nbsp; * <br />
&nbsp; &nbsp; * @author Ali Rantakari<br />
&nbsp; &nbsp; */</span><br />
&nbsp; &nbsp; <span style="color: #0066CC;">public</span> <span style="color: #000000; font-weight: bold;">class</span> VerticalTabNavigator <span style="color: #0066CC;">extends</span> TabNavigator <span style="color: #66cc66;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #808080; font-style: italic;">// copied from superclass:</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0066CC;">private</span> <span style="color: #0066CC;">static</span> const MIN_TAB_WIDTH:<span style="color: #0066CC;">Number</span> = <span style="color: #cc66cc;">30</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0066CC;">private</span> <span style="color: #000000; font-weight: bold;">var</span> _tabBarLocation:<span style="color: #0066CC;">String</span> = <span style="color: #ff0000;">&quot;left&quot;</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #808080; font-style: italic;">/**<br />
&nbsp; &nbsp; &nbsp; &nbsp; * Constructor.<br />
&nbsp; &nbsp; &nbsp; &nbsp; */</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0066CC;">public</span> <span style="color: #000000; font-weight: bold;">function</span> VerticalTabNavigator<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>:<span style="color: #0066CC;">void</span> <span style="color: #66cc66;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0066CC;">super</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #66cc66;">&#125;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #808080; font-style: italic;">// BEGIN: private methods &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; -----------------------------------------------------------</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; protected <span style="color: #000000; font-weight: bold;">function</span> <span style="color: #0066CC;">get</span> tabBarHeight<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>:<span style="color: #0066CC;">Number</span> <span style="color: #66cc66;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #b1b100;">return</span> tabBar.<span style="color: #006600;">getExplicitOrMeasuredWidth</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #66cc66;">&#125;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; protected <span style="color: #000000; font-weight: bold;">function</span> <span style="color: #0066CC;">get</span> tabBarWidth<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>:<span style="color: #0066CC;">Number</span> <span style="color: #66cc66;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">var</span> tabWidth:<span style="color: #0066CC;">Number</span> = <span style="color: #0066CC;">getStyle</span><span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">&quot;tabHeight&quot;</span><span style="color: #66cc66;">&#41;</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #b1b100;">if</span> <span style="color: #66cc66;">&#40;</span><span style="color: #0066CC;">isNaN</span><span style="color: #66cc66;">&#40;</span>tabWidth<span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; tabWidth = tabBar.<span style="color: #006600;">getExplicitOrMeasuredHeight</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #b1b100;">return</span> tabWidth - <span style="color: #cc66cc;">1</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #66cc66;">&#125;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #808080; font-style: italic;">// --end--: private methods &nbsp; &nbsp; - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #808080; font-style: italic;">// BEGIN: overridden methods&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; -----------------------------------------------------------</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #808080; font-style: italic;">/**<br />
&nbsp; &nbsp; &nbsp; &nbsp; * @private<br />
&nbsp; &nbsp; &nbsp; &nbsp; */</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; override protected <span style="color: #000000; font-weight: bold;">function</span> createChildren<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>:<span style="color: #0066CC;">void</span> <span style="color: #66cc66;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0066CC;">super</span>.<span style="color: #006600;">createChildren</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #b1b100;">if</span> <span style="color: #66cc66;">&#40;</span>tabBar<span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; tabBar.<span style="color: #0066CC;">setStyle</span><span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">&quot;paddingLeft&quot;</span>, <span style="color: #cc66cc;">0</span><span style="color: #66cc66;">&#41;</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; tabBar.<span style="color: #0066CC;">setStyle</span><span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">&quot;paddingRight&quot;</span>, <span style="color: #cc66cc;">0</span><span style="color: #66cc66;">&#41;</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #66cc66;">&#125;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #66cc66;">&#125;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #808080; font-style: italic;">/**<br />
&nbsp; &nbsp; &nbsp; &nbsp; * @private<br />
&nbsp; &nbsp; &nbsp; &nbsp; */</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; override protected <span style="color: #000000; font-weight: bold;">function</span> updateDisplayList<span style="color: #66cc66;">&#40;</span>unscaledWidth:<span style="color: #0066CC;">Number</span>, unscaledHeight:<span style="color: #0066CC;">Number</span><span style="color: #66cc66;">&#41;</span>:<span style="color: #0066CC;">void</span> <span style="color: #66cc66;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0066CC;">super</span>.<span style="color: #006600;">updateDisplayList</span><span style="color: #66cc66;">&#40;</span>unscaledWidth, unscaledHeight<span style="color: #66cc66;">&#41;</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #808080; font-style: italic;">// determine the TabBar size based on the height of</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #808080; font-style: italic;">// the container instead of the width</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">var</span> vm:EdgeMetrics = viewMetrics;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">var</span> h:<span style="color: #0066CC;">Number</span> = unscaledHeight - vm.<span style="color: #006600;">top</span> - vm.<span style="color: #006600;">bottom</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">var</span> th:<span style="color: #0066CC;">Number</span> = tabBarWidth + <span style="color: #cc66cc;">1</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">var</span> pw:<span style="color: #0066CC;">Number</span> = tabBar.<span style="color: #006600;">getExplicitOrMeasuredWidth</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; tabBar.<span style="color: #006600;">setActualSize</span><span style="color: #66cc66;">&#40;</span><span style="color: #0066CC;">Math</span>.<span style="color: #0066CC;">min</span><span style="color: #66cc66;">&#40;</span>h, pw<span style="color: #66cc66;">&#41;</span>, th<span style="color: #66cc66;">&#41;</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #808080; font-style: italic;">// rotate and position the TabBar based on the verticalAlign style</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #808080; font-style: italic;">// property and the tabBarLocation property</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">var</span> vAlign:<span style="color: #0066CC;">String</span> = <span style="color: #0066CC;">getStyle</span><span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">&quot;verticalAlign&quot;</span><span style="color: #66cc66;">&#41;</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">var</span> allowedVerticalAlignValues:<span style="color: #0066CC;">Array</span> = <span style="color: #66cc66;">&#91;</span><span style="color: #ff0000;">&quot;top&quot;</span>, <span style="color: #ff0000;">&quot;bottom&quot;</span>, <span style="color: #ff0000;">&quot;middle&quot;</span><span style="color: #66cc66;">&#93;</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #b1b100;">if</span> <span style="color: #66cc66;">&#40;</span>allowedVerticalAlignValues.<span style="color: #0066CC;">indexOf</span><span style="color: #66cc66;">&#40;</span>vAlign<span style="color: #66cc66;">&#41;</span> == <span style="color: #66cc66;">&#40;</span>-<span style="color: #cc66cc;">1</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span> vAlign=<span style="color: #ff0000;">&quot;top&quot;</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #b1b100;">if</span> <span style="color: #66cc66;">&#40;</span>_tabBarLocation == <span style="color: #ff0000;">&quot;left&quot;</span><span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #b1b100;">if</span> <span style="color: #66cc66;">&#40;</span>tabBar.<span style="color: #006600;">rotation</span> <span style="color: #66cc66;">!</span>= <span style="color: #cc66cc;">270</span><span style="color: #66cc66;">&#41;</span> tabBar.<span style="color: #006600;">rotation</span> = <span style="color: #cc66cc;">270</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #b1b100;">if</span> <span style="color: #66cc66;">&#40;</span>vAlign == <span style="color: #ff0000;">&quot;top&quot;</span><span style="color: #66cc66;">&#41;</span> tabBar.<span style="color: #006600;">move</span><span style="color: #66cc66;">&#40;</span><span style="color: #cc66cc;">0</span>,tabBar.<span style="color: #0066CC;">width</span><span style="color: #66cc66;">&#41;</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #b1b100;">else</span> <span style="color: #b1b100;">if</span> <span style="color: #66cc66;">&#40;</span>vAlign == <span style="color: #ff0000;">&quot;middle&quot;</span><span style="color: #66cc66;">&#41;</span> tabBar.<span style="color: #006600;">move</span><span style="color: #66cc66;">&#40;</span><span style="color: #cc66cc;">0</span>,<span style="color: #66cc66;">&#40;</span>unscaledHeight<span style="color: #66cc66;">/</span><span style="color: #cc66cc;">2</span>+tabBar.<span style="color: #0066CC;">width</span><span style="color: #66cc66;">/</span><span style="color: #cc66cc;">2</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #b1b100;">else</span> <span style="color: #b1b100;">if</span> <span style="color: #66cc66;">&#40;</span>vAlign == <span style="color: #ff0000;">&quot;bottom&quot;</span><span style="color: #66cc66;">&#41;</span> tabBar.<span style="color: #006600;">move</span><span style="color: #66cc66;">&#40;</span><span style="color: #cc66cc;">0</span>,unscaledHeight<span style="color: #66cc66;">&#41;</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #66cc66;">&#125;</span><span style="color: #b1b100;">else</span><span style="color: #66cc66;">&#123;</span> <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #b1b100;">if</span> <span style="color: #66cc66;">&#40;</span>tabBar.<span style="color: #006600;">rotation</span> <span style="color: #66cc66;">!</span>= <span style="color: #cc66cc;">90</span><span style="color: #66cc66;">&#41;</span> tabBar.<span style="color: #006600;">rotation</span> = <span style="color: #cc66cc;">90</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #b1b100;">if</span> <span style="color: #66cc66;">&#40;</span>vAlign == <span style="color: #ff0000;">&quot;top&quot;</span><span style="color: #66cc66;">&#41;</span> tabBar.<span style="color: #006600;">move</span><span style="color: #66cc66;">&#40;</span>unscaledWidth,<span style="color: #cc66cc;">0</span><span style="color: #66cc66;">&#41;</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #b1b100;">else</span> <span style="color: #b1b100;">if</span> <span style="color: #66cc66;">&#40;</span>vAlign == <span style="color: #ff0000;">&quot;middle&quot;</span><span style="color: #66cc66;">&#41;</span> tabBar.<span style="color: #006600;">move</span><span style="color: #66cc66;">&#40;</span>unscaledWidth,<span style="color: #66cc66;">&#40;</span>unscaledHeight<span style="color: #66cc66;">/</span><span style="color: #cc66cc;">2</span>-tabBar.<span style="color: #0066CC;">width</span><span style="color: #66cc66;">/</span><span style="color: #cc66cc;">2</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #b1b100;">else</span> <span style="color: #b1b100;">if</span> <span style="color: #66cc66;">&#40;</span>vAlign == <span style="color: #ff0000;">&quot;bottom&quot;</span><span style="color: #66cc66;">&#41;</span> tabBar.<span style="color: #006600;">move</span><span style="color: #66cc66;">&#40;</span>unscaledWidth,unscaledHeight-tabBar.<span style="color: #0066CC;">width</span><span style="color: #66cc66;">&#41;</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #66cc66;">&#125;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #66cc66;">&#125;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #808080; font-style: italic;">/**<br />
&nbsp; &nbsp; &nbsp; &nbsp; * @private<br />
&nbsp; &nbsp; &nbsp; &nbsp; */</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; override protected <span style="color: #000000; font-weight: bold;">function</span> measure<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>:<span style="color: #0066CC;">void</span> <span style="color: #66cc66;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0066CC;">super</span>.<span style="color: #006600;">measure</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #808080; font-style: italic;">// remove the height addition made by superclass (tabs are</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #808080; font-style: italic;">// now on the side, not the top)</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">var</span> removedHeight:<span style="color: #0066CC;">Number</span> = tabBarWidth;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; measuredMinHeight -= removedHeight;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; measuredHeight -= removedHeight;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #808080; font-style: italic;">// add width (same reason as above)</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">var</span> addedWidth:<span style="color: #0066CC;">Number</span> = tabBarWidth;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; measuredMinWidth += addedWidth;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; measuredWidth += addedWidth;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #808080; font-style: italic;">// Make sure there is at least enough room</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #808080; font-style: italic;">// to draw all tabs at their minimum size.</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">var</span> tabWidth:<span style="color: #0066CC;">Number</span> = <span style="color: #0066CC;">getStyle</span><span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">&quot;tabWidth&quot;</span><span style="color: #66cc66;">&#41;</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #b1b100;">if</span> <span style="color: #66cc66;">&#40;</span><span style="color: #0066CC;">isNaN</span><span style="color: #66cc66;">&#40;</span>tabWidth<span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span> tabWidth = <span style="color: #cc66cc;">0</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">var</span> minTabBarWidth:<span style="color: #0066CC;">Number</span> = numChildren <span style="color: #66cc66;">*</span> <span style="color: #0066CC;">Math</span>.<span style="color: #0066CC;">max</span><span style="color: #66cc66;">&#40;</span>tabWidth, MIN_TAB_WIDTH<span style="color: #66cc66;">&#41;</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #808080; font-style: italic;">// Add view metrics.</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">var</span> vm:EdgeMetrics = viewMetrics;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; minTabBarWidth += <span style="color: #66cc66;">&#40;</span>vm.<span style="color: #006600;">top</span> + vm.<span style="color: #006600;">bottom</span><span style="color: #66cc66;">&#41;</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #808080; font-style: italic;">// Add horizontal gaps.</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #b1b100;">if</span> <span style="color: #66cc66;">&#40;</span>numChildren <span style="color: #66cc66;">&gt;</span> <span style="color: #cc66cc;">1</span><span style="color: #66cc66;">&#41;</span> <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; minTabBarWidth += <span style="color: #66cc66;">&#40;</span><span style="color: #0066CC;">getStyle</span><span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">&quot;horizontalGap&quot;</span><span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">*</span> <span style="color: #66cc66;">&#40;</span>numChildren - <span style="color: #cc66cc;">1</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #b1b100;">if</span> <span style="color: #66cc66;">&#40;</span>measuredHeight <span style="color: #66cc66;">&lt;</span> minTabBarWidth<span style="color: #66cc66;">&#41;</span> measuredHeight = minTabBarWidth+tabBarWidth;<br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #66cc66;">&#125;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #808080; font-style: italic;">/**<br />
&nbsp; &nbsp; &nbsp; &nbsp; * @private<br />
&nbsp; &nbsp; &nbsp; &nbsp; */</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; override protected <span style="color: #000000; font-weight: bold;">function</span> <span style="color: #0066CC;">get</span> contentHeight<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>:<span style="color: #0066CC;">Number</span> <span style="color: #66cc66;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #808080; font-style: italic;">// undo content height adjustment made by superclass</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #b1b100;">return</span> <span style="color: #0066CC;">super</span>.<span style="color: #006600;">contentHeight</span> + tabBarWidth;<br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #66cc66;">&#125;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #808080; font-style: italic;">/**<br />
&nbsp; &nbsp; &nbsp; &nbsp; * @private<br />
&nbsp; &nbsp; &nbsp; &nbsp; */</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; override protected <span style="color: #000000; font-weight: bold;">function</span> <span style="color: #0066CC;">get</span> contentWidth<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>:<span style="color: #0066CC;">Number</span> <span style="color: #66cc66;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #808080; font-style: italic;">// adjust content width to accommodate the tab bar</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">var</span> vm:EdgeMetrics = viewMetricsAndPadding;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">var</span> vmLeft:<span style="color: #0066CC;">Number</span> = vm.<span style="color: #0066CC;">left</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">var</span> vmRight:<span style="color: #0066CC;">Number</span> = vm.<span style="color: #0066CC;">right</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #b1b100;">if</span> <span style="color: #66cc66;">&#40;</span><span style="color: #0066CC;">isNaN</span><span style="color: #66cc66;">&#40;</span>vmLeft<span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; vmLeft = <span style="color: #cc66cc;">0</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #b1b100;">if</span> <span style="color: #66cc66;">&#40;</span><span style="color: #0066CC;">isNaN</span><span style="color: #66cc66;">&#40;</span>vmRight<span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; vmRight = <span style="color: #cc66cc;">0</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #b1b100;">return</span> unscaledWidth - tabBarWidth - vmLeft - vmRight;<br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #66cc66;">&#125;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #808080; font-style: italic;">/**<br />
&nbsp; &nbsp; &nbsp; &nbsp; * @private<br />
&nbsp; &nbsp; &nbsp; &nbsp; */</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; override protected <span style="color: #000000; font-weight: bold;">function</span> <span style="color: #0066CC;">get</span> contentX<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>:<span style="color: #0066CC;">Number</span> <span style="color: #66cc66;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #808080; font-style: italic;">// adjust content position to accommodate the tab bar</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">var</span> paddingLeft:<span style="color: #0066CC;">Number</span> = <span style="color: #0066CC;">getStyle</span><span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">&quot;paddingLeft&quot;</span><span style="color: #66cc66;">&#41;</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #b1b100;">if</span> <span style="color: #66cc66;">&#40;</span><span style="color: #0066CC;">isNaN</span><span style="color: #66cc66;">&#40;</span>paddingLeft<span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; paddingLeft = <span style="color: #cc66cc;">0</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #b1b100;">if</span> <span style="color: #66cc66;">&#40;</span>_tabBarLocation == <span style="color: #ff0000;">&quot;left&quot;</span><span style="color: #66cc66;">&#41;</span> <span style="color: #b1b100;">return</span> tabBarWidth + paddingLeft;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #b1b100;">else</span> <span style="color: #b1b100;">return</span> paddingLeft;<br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #66cc66;">&#125;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #808080; font-style: italic;">/**<br />
&nbsp; &nbsp; &nbsp; &nbsp; * @private<br />
&nbsp; &nbsp; &nbsp; &nbsp; */</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; override protected <span style="color: #000000; font-weight: bold;">function</span> <span style="color: #0066CC;">get</span> contentY<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>:<span style="color: #0066CC;">Number</span> <span style="color: #66cc66;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #808080; font-style: italic;">// undo content position adjustment made by superclass</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #b1b100;">return</span> <span style="color: #0066CC;">super</span>.<span style="color: #006600;">contentY</span> - tabBarWidth;<br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #66cc66;">&#125;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #808080; font-style: italic;">/**<br />
&nbsp; &nbsp; &nbsp; &nbsp; * @private<br />
&nbsp; &nbsp; &nbsp; &nbsp; */</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; override protected <span style="color: #000000; font-weight: bold;">function</span> adjustFocusRect<span style="color: #66cc66;">&#40;</span><span style="color: #0066CC;">object</span>:DisplayObject = <span style="color: #000000; font-weight: bold;">null</span><span style="color: #66cc66;">&#41;</span>:<span style="color: #0066CC;">void</span> <span style="color: #66cc66;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0066CC;">super</span>.<span style="color: #006600;">adjustFocusRect</span><span style="color: #66cc66;">&#40;</span><span style="color: #0066CC;">object</span><span style="color: #66cc66;">&#41;</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #808080; font-style: italic;">// Undo changes made by superclass:</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #808080; font-style: italic;">// &quot;Adjust the focus rect so it is below the tabs&quot;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #808080; font-style: italic;">// - and redo the same thing with width instead of height</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">var</span> focusObj:IFlexDisplayObject = IFlexDisplayObject<span style="color: #66cc66;">&#40;</span>getFocusObject<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #b1b100;">if</span> <span style="color: #66cc66;">&#40;</span>focusObj<span style="color: #66cc66;">&#41;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #66cc66;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; focusObj.<span style="color: #006600;">setActualSize</span><span style="color: #66cc66;">&#40;</span>focusObj.<span style="color: #0066CC;">width</span> - tabBarWidth, focusObj.<span style="color: #0066CC;">height</span> + tabBarWidth<span style="color: #66cc66;">&#41;</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #b1b100;">if</span> <span style="color: #66cc66;">&#40;</span>_tabBarLocation == <span style="color: #ff0000;">&quot;left&quot;</span><span style="color: #66cc66;">&#41;</span> focusObj.<span style="color: #006600;">move</span><span style="color: #66cc66;">&#40;</span>focusObj.<span style="color: #006600;">x</span> + tabBarWidth, focusObj.<span style="color: #006600;">y</span> - tabBarWidth<span style="color: #66cc66;">&#41;</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #b1b100;">else</span> focusObj.<span style="color: #006600;">move</span><span style="color: #66cc66;">&#40;</span>focusObj.<span style="color: #006600;">x</span>, focusObj.<span style="color: #006600;">y</span> - tabBarWidth<span style="color: #66cc66;">&#41;</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #b1b100;">if</span> <span style="color: #66cc66;">&#40;</span>focusObj is IInvalidating<span style="color: #66cc66;">&#41;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; IInvalidating<span style="color: #66cc66;">&#40;</span>focusObj<span style="color: #66cc66;">&#41;</span>.<span style="color: #006600;">validateNow</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #b1b100;">else</span> <span style="color: #b1b100;">if</span> <span style="color: #66cc66;">&#40;</span>focusObj is ProgrammaticSkin<span style="color: #66cc66;">&#41;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; ProgrammaticSkin<span style="color: #66cc66;">&#40;</span>focusObj<span style="color: #66cc66;">&#41;</span>.<span style="color: #006600;">validateNow</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #66cc66;">&#125;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #66cc66;">&#125;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #808080; font-style: italic;">/**<br />
&nbsp; &nbsp; &nbsp; &nbsp; * @private<br />
&nbsp; &nbsp; &nbsp; &nbsp; */</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; override protected <span style="color: #000000; font-weight: bold;">function</span> layoutChrome<span style="color: #66cc66;">&#40;</span>unscaledWidth:<span style="color: #0066CC;">Number</span>, unscaledHeight:<span style="color: #0066CC;">Number</span><span style="color: #66cc66;">&#41;</span>:<span style="color: #0066CC;">void</span> <span style="color: #66cc66;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0066CC;">super</span>.<span style="color: #006600;">layoutChrome</span><span style="color: #66cc66;">&#40;</span>unscaledWidth, unscaledHeight<span style="color: #66cc66;">&#41;</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #808080; font-style: italic;">// Undo changes made by superclass:</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #808080; font-style: italic;">// &quot;Move our border so it leaves room for the tabs&quot;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #808080; font-style: italic;">// - and redo the same thing with width instead of height</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #b1b100;">if</span> <span style="color: #66cc66;">&#40;</span><span style="color: #0066CC;">border</span><span style="color: #66cc66;">&#41;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #66cc66;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">var</span> borderOffset:<span style="color: #0066CC;">Number</span> = tabBarWidth;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0066CC;">border</span>.<span style="color: #006600;">setActualSize</span><span style="color: #66cc66;">&#40;</span>unscaledWidth - borderOffset, unscaledHeight<span style="color: #66cc66;">&#41;</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #b1b100;">if</span> <span style="color: #66cc66;">&#40;</span>_tabBarLocation == <span style="color: #ff0000;">&quot;left&quot;</span><span style="color: #66cc66;">&#41;</span> <span style="color: #0066CC;">border</span>.<span style="color: #006600;">move</span><span style="color: #66cc66;">&#40;</span>borderOffset, <span style="color: #cc66cc;">0</span><span style="color: #66cc66;">&#41;</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #b1b100;">else</span> <span style="color: #0066CC;">border</span>.<span style="color: #006600;">move</span> <span style="color: #66cc66;">&#40;</span><span style="color: #cc66cc;">0</span>, <span style="color: #cc66cc;">0</span><span style="color: #66cc66;">&#41;</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #66cc66;">&#125;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #66cc66;">&#125;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #808080; font-style: italic;">// --end--: overridden methods&nbsp; &nbsp; &nbsp; - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #808080; font-style: italic;">// BEGIN: public methods&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; -----------------------------------------------------------</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #808080; font-style: italic;">/**<br />
&nbsp; &nbsp; &nbsp; &nbsp; * The location of the TabBar (left or right). Possible<br />
&nbsp; &nbsp; &nbsp; &nbsp; * values are &lt;code&gt;&quot;left&quot;&lt;/code&gt; and &lt;code&gt;&quot;right&quot;&lt;/code&gt;.<br />
&nbsp; &nbsp; &nbsp; &nbsp; */</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0066CC;">public</span> <span style="color: #000000; font-weight: bold;">function</span> <span style="color: #0066CC;">get</span> tabBarLocation<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>:<span style="color: #0066CC;">String</span> <span style="color: #66cc66;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #b1b100;">return</span> _tabBarLocation;<br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #66cc66;">&#125;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #808080; font-style: italic;">/**<br />
&nbsp; &nbsp; &nbsp; &nbsp; * @private<br />
&nbsp; &nbsp; &nbsp; &nbsp; */</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0066CC;">public</span> <span style="color: #000000; font-weight: bold;">function</span> <span style="color: #0066CC;">set</span> tabBarLocation<span style="color: #66cc66;">&#40;</span>aValue:<span style="color: #0066CC;">String</span><span style="color: #66cc66;">&#41;</span>:<span style="color: #0066CC;">void</span> <span style="color: #66cc66;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #b1b100;">if</span> <span style="color: #66cc66;">&#40;</span>aValue == <span style="color: #ff0000;">&quot;left&quot;</span> <span style="color: #66cc66;">||</span> aValue == <span style="color: #ff0000;">&quot;right&quot;</span><span style="color: #66cc66;">&#41;</span> _tabBarLocation = aValue;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #b1b100;">else</span> <span style="color: #0066CC;">throw</span> <span style="color: #000000; font-weight: bold;">new</span> ArgumentError<span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">&quot;Value for tabBarLocation must be either <span style="color: #000099; font-weight: bold;">\&quot;</span>left<span style="color: #000099; font-weight: bold;">\&quot;</span> or <span style="color: #000099; font-weight: bold;">\&quot;</span>right<span style="color: #000099; font-weight: bold;">\&quot;</span>&quot;</span><span style="color: #66cc66;">&#41;</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #66cc66;">&#125;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #808080; font-style: italic;">// --end--: public methods&nbsp; &nbsp; &nbsp; - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; <span style="color: #66cc66;">&#125;</span><br />
&nbsp; &nbsp; <br />
<span style="color: #66cc66;">&#125;</span></div></div></p>
]]></content:encoded>
			<wfw:commentRss>http://hasseg.org/blog/post/112/vertical-tabnavigator-component-for-flex/feed/</wfw:commentRss>
		<slash:comments>38</slash:comments>
		</item>
		<item>
		<title>ActionScript 3 Support for jEdit&#8217;s SideKick Plugin Through Exuberant Ctags</title>
		<link>http://hasseg.org/blog/post/101/actionscript-3-support-for-jedits-sidekick-plugin-through-exuberant-ctags/</link>
		<comments>http://hasseg.org/blog/post/101/actionscript-3-support-for-jedits-sidekick-plugin-through-exuberant-ctags/#comments</comments>
		<pubDate>Tue, 09 Oct 2007 12:49:04 +0000</pubDate>
		<dc:creator>Ali Rantakari</dc:creator>
				<category><![CDATA[ActionScript 3]]></category>
		<category><![CDATA[Flex]]></category>
		<category><![CDATA[jEdit]]></category>
		<category><![CDATA[Programming]]></category>

		<guid isPermaLink="false">http://hasseg.org/blog/?p=101</guid>
		<description><![CDATA[Today VeryVito made a post on his blog that I had been waiting for a while now: he had just written ActionScript 3 support for Exuberant Ctags, which means proper SideKick plugin support for jEdit when editing AS3 with it. He also made nicer icons for use with the CtagsSideKick, so you should definitely check [...]]]></description>
			<content:encoded><![CDATA[<p>
Today VeryVito made a post on his blog that I had been waiting for a while now: he had just written <a href="http://www.turdhead.com/2007/10/09/almost-perfect-actionscript-code-browsing-with-jedits-sidekick-panel/">ActionScript 3 support</a> for <a href="http://ctags.sourceforge.net/">Exuberant Ctags</a>, which means proper SideKick plugin support for jEdit when editing AS3 with it. He also made nicer icons for use with the CtagsSideKick, so you should definitely <a href="http://www.turdhead.com/2007/10/09/almost-perfect-actionscript-code-browsing-with-jedits-sidekick-panel/">check his stuff out</a> if you use (or plan to use) jEdit for editing AS3.
</p>
<p>
However, after starting to use the SideKick plugin with the modified, AS3-supported version of Ctags while doing my work, I found a few small rough edges in the ActionScript support he had made:
</p>
<p><span id="more-101"></span></p>
<ul>
<li>Package names were not properly catched &#8211; only the first level was shown (e.g. &#8220;<em>org</em>&#8221; instead of &#8220;<em>org.hasseg.thingamabob</em>&#8220;)</li>
<li>Todo and note names were not properly catched &#8211; it just showed &#8220;<em>todo</em>&#8221; or &#8220;<em>note</em>&#8221; instead of what comes after</li>
<li>My &#8220;<em>todo:</em>&#8221; notes were not catched &#8211; it only supported uppercase (i.e. &#8220;<em>TODO:</em>&#8220;)</li>
<li>Some attribute keywords (<em>override</em>, <em>final</em>, <em>internal</em> etc&#8230;) were not allowed on classes, functions/methods and properties, so I was missing some of these in my SideKick listings</li>
</ul>
<p>Not big problems by any means, but for me these meant that SideKick wouldn&#8217;t display some of the stuff in my code, and if it did, not properly, so I fixed them.
</p>
<p>
Get my modified version of the AS3-supported Ctags here:
</p>
<p>
<a href="/stuff/AS3Ctags/ctags.zip">The ctags binary (zipped)</a> (<em>note: compiled on a rev.B MacBook (Core 2 Duo processor) with Mac OS 10.4.10</em>)
</p>
<p>
<a href="/stuff/AS3Ctags/actionscript.c">The source code (actionscript.c)</a>
</p>
<p>
You should refer to <a href="http://www.turdhead.com/2007/10/09/almost-perfect-actionscript-code-browsing-with-jedits-sidekick-panel/">VeryVito&#8217;s post</a> for more info this issue.
</p>
<p>
<em>Update (same day as original post): Improved this a bit. Find below a complete list of changes I&#8217;ve made (taken from the source code):</p>
<div class="codecolorer-container c mac-classic codecolorer-customstyle" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><div class="c codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color: #808080; font-style: italic;">/*<br />
* - Added more allowed AS3 attribute keywords (override, final, internal <br />
* &nbsp; etc...) for classes, getters &amp; setters, variables<br />
* - Allowed varying versions of &quot;note&quot; and &quot;todo&quot; spellings<br />
* - Allowed points (.) in package names so that they would display the<br />
* &nbsp; whole package name instead of just the first level<br />
* - Added interfaces matching support<br />
* - Reformatted some name parameters:<br />
* - Getters and setters: display either &quot;get&quot; or &quot;set&quot; in front<br />
* &nbsp; of the property name<br />
* - Todos &amp; notes: made the name be the text that comes after the<br />
* &nbsp; &quot;todo&quot; or &quot;note&quot; text<br />
* - Variables: Moved the variable type after the name and separated<br />
* &nbsp; them with &quot; : &quot; according to ActionScript syntax<br />
*/</span></div></div>
<p></em></p>
]]></content:encoded>
			<wfw:commentRss>http://hasseg.org/blog/post/101/actionscript-3-support-for-jedits-sidekick-plugin-through-exuberant-ctags/feed/</wfw:commentRss>
		<slash:comments>5</slash:comments>
		</item>
		<item>
		<title>Flex SDK Language Reference Helper Macro for jEdit</title>
		<link>http://hasseg.org/blog/post/98/flex-sdk-language-reference-helper-macro-for-jedit/</link>
		<comments>http://hasseg.org/blog/post/98/flex-sdk-language-reference-helper-macro-for-jedit/#comments</comments>
		<pubDate>Mon, 01 Oct 2007 15:12:07 +0000</pubDate>
		<dc:creator>Ali Rantakari</dc:creator>
				<category><![CDATA[ActionScript 3]]></category>
		<category><![CDATA[Flex]]></category>
		<category><![CDATA[jEdit]]></category>
		<category><![CDATA[Mac]]></category>
		<category><![CDATA[Programming]]></category>

		<guid isPermaLink="false">http://hasseg.org/blog/?p=98</guid>
		<description><![CDATA[VeryVito at turdhead.com has been writing lately about customizing jEdit for writing ActionScript, which is exactly what I&#8217;ve also been doing. A While ago he posted macros for referencing the help files that came with Flash CS3. Well, I don&#8217;t have Flash CS3, and I use the Flex SDK to do my ActionScripting, so I [...]]]></description>
			<content:encoded><![CDATA[<p>
VeryVito at <a href="http://www.turdhead.com">turdhead.com</a> has been writing lately about <a href="http://www.turdhead.com/jedit-and-actionscript-the-collected-files/">customizing jEdit for writing ActionScript</a>, which is exactly what I&#8217;ve also been doing. A While ago he posted <a href="http://www.turdhead.com/2007/09/30/more-actionscript-magic-for-jedit-context-sensitive-reference-material/">macros for referencing the help files</a> that came with Flash CS3. Well, I don&#8217;t have Flash CS3, and I use the Flex SDK to do my ActionScripting, so I took the macro he posted and modified it so that it can be used with the Flex language reference.
</p>
<p>
<em><b>Update (Oct 5, 07)</b>: Now it can search from any number of AsDoc sources</em><br />
<em><b>Update (Oct 8, 07)</b>: Also finds documentation for methods, changing the command for opening a file in a web browser is easier</em><br />
<em><b>Update (Oct 10, 07)</b>: now the script searches through files, not buffers, so you needn&#8217;t have all of your project&#8217;s files open for it to be able to search through them</em>
</p>
<p><span id="more-98"></span></p>
<p>
The way my version works is that it gets the selection from the current buffer (or if there&#8217;s no selection made, it selects the word that the caret is on top of) and searches the Flex SDK language reference for it. The files it goes through and the regular expressions + other logic that is used to do the pattern matching are designed so that it would work for class, package and method names.
</p>
<p>
Here&#8217;s the macro code (with some unnecessary whitespace removed):</p>
<div class="codecolorer-container java mac-classic codecolorer-customstyle" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;height:300px;"><div class="java codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color: #666666; font-style: italic;">/*<br />
* Copyright (c) 2007 Ali Rantakari<br />
* <br />
* fromjeditflexlangrefmacro.20.hasseg@spamgourmet.com<br />
* http://hasseg.org<br />
* <br />
* Based on macros by VeryVito from turdhead.com :<br />
* http://www.turdhead.com/2007/09/30/more-actionscript-magic-for-jedit-context-sensitive-reference-material/<br />
* <br />
* thanks!<br />
* <br />
* ---------------------------------------------------------------------------<br />
* <br />
* DESCRIPTION:<br />
* <br />
* A jEdit macro for displaying Flex SDK language reference documentation<br />
* for a selected class, package or method.<br />
* <br />
* Developed and tested only on OS X, no guarantee of this working on <br />
* other platforms.<br />
* <br />
* ---------------------------------------------------------------------------<br />
* <br />
* REQUIRES:<br />
* <br />
* - jEdit<br />
* <br />
* - OPTIONAL: InfoViewer plugin for jEdit<br />
* <br />
* ---------------------------------------------------------------------------<br />
* <br />
* USAGE:<br />
* <br />
* 1) Change the settings below to correspond to your system<br />
* <br />
* 2) Add this to your macros folder ( ~/.jedit/macros )<br />
* <br />
* 3) Bind it to a keyboard shortcut ( utilities -&gt; global options -&gt;<br />
* &nbsp; &nbsp;shortcuts -&gt; macros )<br />
* <br />
* 4) Place your pointer on the search term or select the search<br />
* &nbsp; &nbsp;term (an AS3/Flex class, package or method name)<br />
* <br />
* 5) Run the macro by pressing the shortcut you assigned (or from<br />
* &nbsp; &nbsp;the macros menu)<br />
* <br />
* ---------------------------------------------------------------------------<br />
* <br />
* Licensed under the MIT License:<br />
* <br />
* Permission is hereby granted, free of charge, to any person obtaining a copy<br />
* of this software and associated documentation files (the &quot;Software&quot;), to deal<br />
* in the Software without restriction, including without limitation the rights<br />
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell<br />
* copies of the Software, and to permit persons to whom the Software is<br />
* furnished to do so, subject to the following conditions:<br />
* <br />
* The above copyright notice and this permission notice shall be included in<br />
* all copies or substantial portions of the Software.<br />
* <br />
* THE SOFTWARE IS PROVIDED &quot;AS IS&quot;, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR<br />
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,<br />
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE<br />
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER<br />
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,<br />
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN<br />
* THE SOFTWARE.<br />
*/</span><br />
<br />
<br />
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">java.util.regex.*</span><span style="color: #339933;">;</span><br />
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">java.text.MessageFormat</span><span style="color: #339933;">;</span><br />
<br />
<br />
<br />
<span style="color: #666666; font-style: italic;">// SETTINGS: --------------------------------------</span><br />
&nbsp; &nbsp; <br />
&nbsp; &nbsp; <span style="color: #666666; font-style: italic;">/*<br />
&nbsp; &nbsp; * Paths to AsDoc folders to search (in this order)<br />
&nbsp; &nbsp; * (with trailing slashes)<br />
&nbsp; &nbsp; */</span><br />
&nbsp; &nbsp; <span style="color: #003399;">String</span><span style="color: #009900;">&#91;</span><span style="color: #009900;">&#93;</span> foldersToCheck <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> <span style="color: #003399;">String</span><span style="color: #009900;">&#91;</span><span style="color: #009900;">&#93;</span> <span style="color: #009900;">&#123;</span>&nbsp; &nbsp; <span style="color: #0000ff;">&quot;/Flex/flex201_documentation/langref/&quot;</span>,<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0000ff;">&quot;/Flex/SVN_working_copies/SSGUI-Flex/asdoc-output/&quot;</span><span style="color: #009900;">&#125;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; <br />
&nbsp; &nbsp; <span style="color: #666666; font-style: italic;">/*<br />
&nbsp; &nbsp; * The files in the AsDoc folders to check (in this order)<br />
&nbsp; &nbsp; * (if they don't exist in all of the folders, no worries)<br />
&nbsp; &nbsp; */</span><br />
&nbsp; &nbsp; <span style="color: #003399;">String</span><span style="color: #009900;">&#91;</span><span style="color: #009900;">&#93;</span> filesToCheck <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> <span style="color: #003399;">String</span><span style="color: #009900;">&#91;</span><span style="color: #009900;">&#93;</span> <span style="color: #009900;">&#123;</span>&nbsp; <span style="color: #0000ff;">&quot;all-classes.html&quot;</span>, <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0000ff;">&quot;class-list.html&quot;</span>, <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0000ff;">&quot;package-summary.html&quot;</span><span style="color: #009900;">&#125;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; <br />
&nbsp; &nbsp; <br />
&nbsp; &nbsp; <br />
&nbsp; &nbsp; <span style="color: #666666; font-style: italic;">/*<br />
&nbsp; &nbsp; * Whether to display the found documentation page<br />
&nbsp; &nbsp; * in the InfoViewer plugin or not (if not, the<br />
&nbsp; &nbsp; * openCommand (below) will be run in the console)<br />
&nbsp; &nbsp; */</span><br />
&nbsp; &nbsp; displayInInfoViewer <span style="color: #339933;">=</span> <span style="color: #000066; font-weight: bold;">false</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; <br />
&nbsp; &nbsp; <br />
&nbsp; &nbsp; <span style="color: #666666; font-style: italic;">/*<br />
&nbsp; &nbsp; * The command to run in the console for opening<br />
&nbsp; &nbsp; * the found documentation file in, for example,<br />
&nbsp; &nbsp; * a web browser<br />
&nbsp; &nbsp; * <br />
&nbsp; &nbsp; * {0} will be substituted with the filename to open,<br />
&nbsp; &nbsp; * &nbsp; &nbsp; surrounded by double quotes (so don't add the<br />
&nbsp; &nbsp; * &nbsp; &nbsp; double quotes here)<br />
&nbsp; &nbsp; */</span><br />
&nbsp; &nbsp; openCommand <span style="color: #339933;">=</span> <span style="color: #0000ff;">&quot;open -a Safari {0}&quot;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; <br />
&nbsp; &nbsp; <br />
<span style="color: #666666; font-style: italic;">// /settings - - - - - - - - - - - - - - - - - - - </span><br />
<br />
<br />
<br />
<span style="color: #666666; font-style: italic;">// Macro implementation begins here: &nbsp;------------</span><br />
<br />
<br />
<br />
<span style="color: #666666; font-style: italic;">// functions -------------------------------------</span><br />
<br />
<br />
<span style="color: #003399;">Vector</span> searchDirForFilesMatching<span style="color: #009900;">&#40;</span><span style="color: #003399;">File</span> aDirectory, <span style="color: #003399;">String</span> aRegEx<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span><br />
&nbsp; &nbsp; <span style="color: #003399;">Vector</span> retVal <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> <span style="color: #003399;">Vector</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">if</span> <span style="color: #009900;">&#40;</span>aDirectory <span style="color: #339933;">!=</span> <span style="color: #000066; font-weight: bold;">null</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">if</span> <span style="color: #009900;">&#40;</span>aDirectory.<span style="color: #006633;">exists</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">if</span> <span style="color: #009900;">&#40;</span>aDirectory.<span style="color: #006633;">isDirectory</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #003399;">File</span><span style="color: #009900;">&#91;</span><span style="color: #009900;">&#93;</span> files <span style="color: #339933;">=</span> aDirectory.<span style="color: #006633;">listFiles</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">for</span> <span style="color: #009900;">&#40;</span><span style="color: #000066; font-weight: bold;">int</span> i <span style="color: #339933;">=</span> <span style="color: #cc66cc;">0</span><span style="color: #339933;">;</span> i <span style="color: #339933;">&lt;</span> files.<span style="color: #006633;">length</span><span style="color: #339933;">;</span> i<span style="color: #339933;">++</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">if</span> <span style="color: #009900;">&#40;</span>files<span style="color: #009900;">&#91;</span>i<span style="color: #009900;">&#93;</span>.<span style="color: #006633;">isFile</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">&amp;&amp;</span> <span style="color: #339933;">!</span>files<span style="color: #009900;">&#91;</span>i<span style="color: #009900;">&#93;</span>.<span style="color: #006633;">isHidden</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">if</span> <span style="color: #009900;">&#40;</span>files<span style="color: #009900;">&#91;</span>i<span style="color: #009900;">&#93;</span>.<span style="color: #006633;">getName</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span>.<span style="color: #006633;">matches</span><span style="color: #009900;">&#40;</span>aRegEx<span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span> retVal.<span style="color: #006633;">add</span><span style="color: #009900;">&#40;</span>files<span style="color: #009900;">&#91;</span>i<span style="color: #009900;">&#93;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900;">&#125;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900;">&#125;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900;">&#125;</span><span style="color: #000000; font-weight: bold;">else</span><span style="color: #009900;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; Macros.<span style="color: #006633;">error</span><span style="color: #009900;">&#40;</span>view, <span style="color: #0000ff;">&quot;<span style="color: #000099; font-weight: bold;">\&quot;</span>&quot;</span><span style="color: #339933;">+</span>aDirectory.<span style="color: #006633;">getPath</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">+</span><span style="color: #0000ff;">&quot;<span style="color: #000099; font-weight: bold;">\&quot;</span> is not a directory&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900;">&#125;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900;">&#125;</span><span style="color: #000000; font-weight: bold;">else</span><span style="color: #009900;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; Macros.<span style="color: #006633;">error</span><span style="color: #009900;">&#40;</span>view, <span style="color: #0000ff;">&quot;<span style="color: #000099; font-weight: bold;">\&quot;</span>&quot;</span><span style="color: #339933;">+</span>aDirectory.<span style="color: #006633;">getPath</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">+</span><span style="color: #0000ff;">&quot;<span style="color: #000099; font-weight: bold;">\&quot;</span> does not exist!&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900;">&#125;</span><br />
&nbsp; &nbsp; <span style="color: #009900;">&#125;</span><br />
&nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">return</span> retVal<span style="color: #339933;">;</span><br />
<span style="color: #009900;">&#125;</span><br />
<br />
<br />
<br />
<span style="color: #008000; font-style: italic; font-weight: bold;">/**<br />
* Returns a Vector of HashMaps. Each HashMap contains a match, where<br />
* the keys are the specified group numbers and the values are the<br />
* corresponding strings.<br />
* <br />
* Returns null if no matches.<br />
*/</span><br />
<span style="color: #003399;">Vector</span> regExSearchFile<span style="color: #009900;">&#40;</span><span style="color: #003399;">String</span> aRegEx, <span style="color: #003399;">String</span> aFilePath, <span style="color: #000066; font-weight: bold;">int</span><span style="color: #009900;">&#91;</span><span style="color: #009900;">&#93;</span> aGroupsToReturn<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span><br />
&nbsp; &nbsp; <span style="color: #003399;">Vector</span> retVal <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> <span style="color: #003399;">Vector</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; Pattern regPat <span style="color: #339933;">=</span> Pattern.<span style="color: #006633;">compile</span><span style="color: #009900;">&#40;</span>aRegEx<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; Matcher matcher<span style="color: #339933;">;</span><br />
&nbsp; &nbsp; <span style="color: #003399;">BufferedReader</span> bufr<span style="color: #339933;">;</span><br />
&nbsp; &nbsp; <span style="color: #003399;">File</span> f <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> <span style="color: #003399;">File</span><span style="color: #009900;">&#40;</span>aFilePath<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">if</span> <span style="color: #009900;">&#40;</span>f.<span style="color: #006633;">exists</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">try</span> <span style="color: #009900;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; bufr <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> <span style="color: #003399;">BufferedReader</span> <span style="color: #009900;">&#40;</span><span style="color: #000000; font-weight: bold;">new</span> <span style="color: #003399;">FileReader</span> <span style="color: #009900;">&#40;</span>aFilePath<span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">while</span> <span style="color: #009900;">&#40;</span> <span style="color: #009900;">&#40;</span>record <span style="color: #339933;">=</span> bufr.<span style="color: #006633;">readLine</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">!=</span> <span style="color: #000066; font-weight: bold;">null</span> <span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; matcher <span style="color: #339933;">=</span> regPat.<span style="color: #006633;">matcher</span><span style="color: #009900;">&#40;</span>record<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">if</span> <span style="color: #009900;">&#40;</span>matcher.<span style="color: #006633;">find</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #003399;">HashMap</span> thisRetEntry <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> <span style="color: #003399;">HashMap</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">for</span> <span style="color: #009900;">&#40;</span><span style="color: #000066; font-weight: bold;">int</span> j <span style="color: #339933;">=</span> <span style="color: #cc66cc;">0</span><span style="color: #339933;">;</span> j <span style="color: #339933;">&lt;</span> aGroupsToReturn.<span style="color: #006633;">length</span><span style="color: #339933;">;</span> j<span style="color: #339933;">++</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; thisRetEntry.<span style="color: #006633;">put</span><span style="color: #009900;">&#40;</span>aGroupsToReturn<span style="color: #009900;">&#91;</span>j<span style="color: #009900;">&#93;</span>, matcher.<span style="color: #006633;">group</span><span style="color: #009900;">&#40;</span>aGroupsToReturn<span style="color: #009900;">&#91;</span>j<span style="color: #009900;">&#93;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900;">&#125;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; retVal.<span style="color: #006633;">add</span><span style="color: #009900;">&#40;</span>thisRetEntry<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900;">&#125;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900;">&#125;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900;">&#125;</span> <span style="color: #000000; font-weight: bold;">catch</span> <span style="color: #009900;">&#40;</span>java.<span style="color: #006633;">io</span>.<span style="color: #003399;">IOException</span> e<span style="color: #009900;">&#41;</span> &nbsp;<span style="color: #009900;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; Macros.<span style="color: #006633;">error</span><span style="color: #009900;">&#40;</span>view, <span style="color: #0000ff;">&quot;An error occurred while trying to parse <span style="color: #000099; font-weight: bold;">\&quot;</span>&quot;</span><span style="color: #339933;">+</span>aFilePath<span style="color: #339933;">+</span><span style="color: #0000ff;">&quot;<span style="color: #000099; font-weight: bold;">\&quot;</span>&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900;">&#125;</span><br />
&nbsp; &nbsp; <span style="color: #009900;">&#125;</span><br />
&nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">return</span> retVal<span style="color: #339933;">;</span><br />
<span style="color: #009900;">&#125;</span><br />
<br />
<br />
<br />
<span style="color: #008000; font-style: italic; font-weight: bold;">/**<br />
* Searches for the specified class or package name (aWordToFind) in<br />
* the AsDoc folders and files specified in the settings.<br />
* <br />
* Returns the documentation file path or null if not found.<br />
*/</span><br />
<span style="color: #003399;">String</span> searchForDocs<span style="color: #009900;">&#40;</span><span style="color: #003399;">String</span> aWordToFind<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span><br />
&nbsp; &nbsp; <span style="color: #003399;">String</span> retVal <span style="color: #339933;">=</span> <span style="color: #000066; font-weight: bold;">null</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; <span style="color: #003399;">String</span> regEx <span style="color: #339933;">=</span> <span style="color: #0000ff;">&quot;a.*href<span style="color: #000099; font-weight: bold;">\\</span>s*=<span style="color: #000099; font-weight: bold;">\\</span>s*<span style="color: #000099; font-weight: bold;">\&quot;</span>(.*?)<span style="color: #000099; font-weight: bold;">\&quot;</span>.*&gt;(&quot;</span><span style="color: #339933;">+</span>aWordToFind<span style="color: #339933;">+</span><span style="color: #0000ff;">&quot;)&lt;&quot;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; Pattern regPat <span style="color: #339933;">=</span> Pattern.<span style="color: #006633;">compile</span><span style="color: #009900;">&#40;</span>regEx<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; Matcher matcher<span style="color: #339933;">;</span><br />
&nbsp; &nbsp; <span style="color: #003399;">BufferedReader</span> bufr<span style="color: #339933;">;</span><br />
&nbsp; &nbsp; <span style="color: #000066; font-weight: bold;">int</span> j <span style="color: #339933;">=</span> <span style="color: #cc66cc;">0</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">while</span> <span style="color: #009900;">&#40;</span><span style="color: #009900;">&#40;</span>retVal <span style="color: #339933;">==</span> <span style="color: #000066; font-weight: bold;">null</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">&amp;&amp;</span> <span style="color: #009900;">&#40;</span>j <span style="color: #339933;">&lt;</span> foldersToCheck.<span style="color: #006633;">length</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000066; font-weight: bold;">int</span> i <span style="color: #339933;">=</span> <span style="color: #cc66cc;">0</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">while</span> <span style="color: #009900;">&#40;</span><span style="color: #009900;">&#40;</span>retVal <span style="color: #339933;">==</span> <span style="color: #000066; font-weight: bold;">null</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">&amp;&amp;</span> <span style="color: #009900;">&#40;</span>i <span style="color: #339933;">&lt;</span> filesToCheck.<span style="color: #006633;">length</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #003399;">String</span> thisFile <span style="color: #339933;">=</span> foldersToCheck<span style="color: #009900;">&#91;</span>j<span style="color: #009900;">&#93;</span><span style="color: #339933;">+</span>filesToCheck<span style="color: #009900;">&#91;</span>i<span style="color: #009900;">&#93;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #003399;">File</span> f <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> <span style="color: #003399;">File</span><span style="color: #009900;">&#40;</span>thisFile<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">if</span> <span style="color: #009900;">&#40;</span>f.<span style="color: #006633;">exists</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">try</span> <span style="color: #009900;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; bufr <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> <span style="color: #003399;">BufferedReader</span> <span style="color: #009900;">&#40;</span><span style="color: #000000; font-weight: bold;">new</span> <span style="color: #003399;">FileReader</span> <span style="color: #009900;">&#40;</span>thisFile<span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">while</span> <span style="color: #009900;">&#40;</span> <span style="color: #009900;">&#40;</span>record <span style="color: #339933;">=</span> bufr.<span style="color: #006633;">readLine</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">!=</span> <span style="color: #000066; font-weight: bold;">null</span> <span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; matcher <span style="color: #339933;">=</span> regPat.<span style="color: #006633;">matcher</span><span style="color: #009900;">&#40;</span>record<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">if</span> <span style="color: #009900;">&#40;</span>matcher.<span style="color: #006633;">find</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span> retVal <span style="color: #339933;">=</span> foldersToCheck<span style="color: #009900;">&#91;</span>j<span style="color: #009900;">&#93;</span> <span style="color: #339933;">+</span> matcher.<span style="color: #006633;">group</span><span style="color: #009900;">&#40;</span><span style="color: #cc66cc;">1</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900;">&#125;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900;">&#125;</span> <span style="color: #000000; font-weight: bold;">catch</span> <span style="color: #009900;">&#40;</span>java.<span style="color: #006633;">io</span>.<span style="color: #003399;">IOException</span> e<span style="color: #009900;">&#41;</span> &nbsp;<span style="color: #009900;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; Macros.<span style="color: #006633;">error</span><span style="color: #009900;">&#40;</span>view, <span style="color: #0000ff;">&quot;An error occurred while trying to parse <span style="color: #000099; font-weight: bold;">\&quot;</span>&quot;</span><span style="color: #339933;">+</span>thisFile<span style="color: #339933;">+</span><span style="color: #0000ff;">&quot;<span style="color: #000099; font-weight: bold;">\&quot;</span>&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900;">&#125;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900;">&#125;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; i<span style="color: #339933;">++;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900;">&#125;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; j<span style="color: #339933;">++;</span><br />
&nbsp; &nbsp; <span style="color: #009900;">&#125;</span><br />
&nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">return</span> retVal<span style="color: #339933;">;</span><br />
<span style="color: #009900;">&#125;</span><br />
<br />
<br />
<span style="color: #008000; font-style: italic; font-weight: bold;">/**<br />
* Give this a variable name and the path to the file where<br />
* it appears, and get the class name of the type<br />
* of the variable, or null if not found.<br />
*/</span><br />
<span style="color: #003399;">String</span> findTypeOfVarFromFile<span style="color: #009900;">&#40;</span><span style="color: #003399;">String</span> aVarName, <span style="color: #003399;">String</span> aFilePath<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span><br />
&nbsp; &nbsp; <span style="color: #003399;">String</span> retVal <span style="color: #339933;">=</span> <span style="color: #000066; font-weight: bold;">null</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; <span style="color: #003399;">File</span> f <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> <span style="color: #003399;">File</span><span style="color: #009900;">&#40;</span>aFilePath<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">if</span> <span style="color: #009900;">&#40;</span>f.<span style="color: #006633;">exists</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">if</span> <span style="color: #009900;">&#40;</span>f.<span style="color: #006633;">isFile</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; returnCurrentClassName <span style="color: #339933;">=</span> <span style="color: #000066; font-weight: bold;">false</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">if</span> <span style="color: #009900;">&#40;</span>aVarName <span style="color: #339933;">==</span> <span style="color: #000066; font-weight: bold;">null</span><span style="color: #009900;">&#41;</span> returnCurrentClassName <span style="color: #339933;">=</span> <span style="color: #000066; font-weight: bold;">true</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">else</span> <span style="color: #000000; font-weight: bold;">if</span> <span style="color: #009900;">&#40;</span>aVarName <span style="color: #339933;">==</span> <span style="color: #0000ff;">&quot;this&quot;</span> <span style="color: #339933;">||</span> aVarName.<span style="color: #006633;">trim</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">==</span> <span style="color: #0000ff;">&quot;&quot;</span><span style="color: #009900;">&#41;</span> returnCurrentClassName <span style="color: #339933;">=</span> <span style="color: #000066; font-weight: bold;">true</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">if</span> <span style="color: #009900;">&#40;</span>returnCurrentClassName <span style="color: #339933;">==</span> <span style="color: #000066; font-weight: bold;">true</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #666666; font-style: italic;">// find first class name from specified file</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #003399;">Vector</span> results <span style="color: #339933;">=</span> regExSearchFile<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;<span style="color: #000099; font-weight: bold;">\\</span>b(class)<span style="color: #000099; font-weight: bold;">\\</span>s+<span style="color: #000099; font-weight: bold;">\\</span>b(<span style="color: #000099; font-weight: bold;">\\</span>w+)<span style="color: #000099; font-weight: bold;">\\</span>b&quot;</span>, aFilePath, <span style="color: #000000; font-weight: bold;">new</span> <span style="color: #000066; font-weight: bold;">int</span><span style="color: #009900;">&#91;</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#123;</span><span style="color: #cc66cc;">2</span><span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #339933;">!</span>results.<span style="color: #006633;">isEmpty</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span> retVal <span style="color: #339933;">=</span> results.<span style="color: #006633;">get</span><span style="color: #009900;">&#40;</span><span style="color: #cc66cc;">0</span><span style="color: #009900;">&#41;</span>.<span style="color: #006633;">get</span><span style="color: #009900;">&#40;</span><span style="color: #cc66cc;">2</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900;">&#125;</span><span style="color: #000000; font-weight: bold;">else</span><span style="color: #009900;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #666666; font-style: italic;">// find definition of specified variable from specified file</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #003399;">Vector</span> results <span style="color: #339933;">=</span> regExSearchFile<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;.*(&quot;</span><span style="color: #339933;">+</span>aVarName<span style="color: #339933;">+</span><span style="color: #0000ff;">&quot;)<span style="color: #000099; font-weight: bold;">\\</span>s*:<span style="color: #000099; font-weight: bold;">\\</span>s*(.*?)[;,=<span style="color: #000099; font-weight: bold;">\\</span>s<span style="color: #000099; font-weight: bold;">\\</span>)]+&quot;</span><span style="color: #009900;">&#41;</span>, aFilePath, <span style="color: #000000; font-weight: bold;">new</span> <span style="color: #000066; font-weight: bold;">int</span><span style="color: #009900;">&#91;</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#123;</span><span style="color: #cc66cc;">2</span><span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #339933;">!</span>results.<span style="color: #006633;">isEmpty</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; retVal <span style="color: #339933;">=</span> results.<span style="color: #006633;">get</span><span style="color: #009900;">&#40;</span><span style="color: #cc66cc;">0</span><span style="color: #009900;">&#41;</span>.<span style="color: #006633;">get</span><span style="color: #009900;">&#40;</span><span style="color: #cc66cc;">2</span><span style="color: #009900;">&#41;</span>.<span style="color: #006633;">trim</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #666666; font-style: italic;">// if file classname+&quot;class.as&quot; exists, prefer that class name</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #003399;">Vector</span> codeBehindMatches <span style="color: #339933;">=</span> searchDirForFilesMatching<span style="color: #009900;">&#40;</span>f.<span style="color: #006633;">getParentFile</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span>, <span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;^&quot;</span><span style="color: #339933;">+</span>retVal<span style="color: #339933;">+</span><span style="color: #0000ff;">&quot;Class<span style="color: #000099; font-weight: bold;">\\</span>.as$&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #339933;">!</span>codeBehindMatches.<span style="color: #006633;">isEmpty</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span> retVal <span style="color: #339933;">=</span> retVal<span style="color: #339933;">+</span><span style="color: #0000ff;">&quot;Class&quot;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900;">&#125;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #666666; font-style: italic;">// if nothing found...</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">if</span> <span style="color: #009900;">&#40;</span>retVal <span style="color: #339933;">==</span> <span style="color: #000066; font-weight: bold;">null</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #666666; font-style: italic;">// find superclass name (if there is one)</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #003399;">Vector</span> results <span style="color: #339933;">=</span> regExSearchFile<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;class<span style="color: #000099; font-weight: bold;">\\</span>s+(.*?)<span style="color: #000099; font-weight: bold;">\\</span>s+extends<span style="color: #000099; font-weight: bold;">\\</span>s+(.*?)[;<span style="color: #000099; font-weight: bold;">\\</span>s]+&quot;</span><span style="color: #009900;">&#41;</span>, aFilePath, <span style="color: #000000; font-weight: bold;">new</span> <span style="color: #000066; font-weight: bold;">int</span><span style="color: #009900;">&#91;</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#123;</span><span style="color: #cc66cc;">2</span><span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #339933;">!</span>results.<span style="color: #006633;">isEmpty</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #003399;">String</span> superClassName <span style="color: #339933;">=</span> results.<span style="color: #006633;">get</span><span style="color: #009900;">&#40;</span><span style="color: #cc66cc;">0</span><span style="color: #009900;">&#41;</span>.<span style="color: #006633;">get</span><span style="color: #009900;">&#40;</span><span style="color: #cc66cc;">2</span><span style="color: #009900;">&#41;</span>.<span style="color: #006633;">trim</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #666666; font-style: italic;">// find source file for superclass (in the same dir)</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #003399;">File</span> superClassFile <span style="color: #339933;">=</span> <span style="color: #000066; font-weight: bold;">null</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #003399;">Vector</span> straightMatches <span style="color: #339933;">=</span> searchDirForFilesMatching<span style="color: #009900;">&#40;</span>f.<span style="color: #006633;">getParentFile</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span>, <span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;^&quot;</span><span style="color: #339933;">+</span>superClassName<span style="color: #339933;">+</span><span style="color: #0000ff;">&quot;<span style="color: #000099; font-weight: bold;">\\</span>.as$&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #003399;">Vector</span> codeBehindMatches <span style="color: #339933;">=</span> searchDirForFilesMatching<span style="color: #009900;">&#40;</span>f.<span style="color: #006633;">getParentFile</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span>, <span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;^&quot;</span><span style="color: #339933;">+</span>superClassName<span style="color: #339933;">+</span><span style="color: #0000ff;">&quot;Class<span style="color: #000099; font-weight: bold;">\\</span>.as$&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #339933;">!</span>codeBehindMatches.<span style="color: #006633;">isEmpty</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span> superClassFile <span style="color: #339933;">=</span> codeBehindMatches.<span style="color: #006633;">get</span><span style="color: #009900;">&#40;</span><span style="color: #cc66cc;">0</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">else</span> <span style="color: #000000; font-weight: bold;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #339933;">!</span>straightMatches.<span style="color: #006633;">isEmpty</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span> superClassFile <span style="color: #339933;">=</span> straightMatches.<span style="color: #006633;">get</span><span style="color: #009900;">&#40;</span><span style="color: #cc66cc;">0</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">if</span> <span style="color: #009900;">&#40;</span>superClassFile <span style="color: #339933;">!=</span> <span style="color: #000066; font-weight: bold;">null</span><span style="color: #009900;">&#41;</span> retVal <span style="color: #339933;">=</span> findTypeOfVarFromFile<span style="color: #009900;">&#40;</span>aVarName, superClassFile.<span style="color: #006633;">getPath</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900;">&#125;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900;">&#125;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900;">&#125;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900;">&#125;</span><span style="color: #000000; font-weight: bold;">else</span><span style="color: #009900;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; Macros.<span style="color: #006633;">error</span><span style="color: #009900;">&#40;</span>view, <span style="color: #0000ff;">&quot;<span style="color: #000099; font-weight: bold;">\&quot;</span>&quot;</span><span style="color: #339933;">+</span>aFilePath<span style="color: #339933;">+</span><span style="color: #0000ff;">&quot;<span style="color: #000099; font-weight: bold;">\&quot;</span> is not a file!&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900;">&#125;</span><br />
&nbsp; &nbsp; <span style="color: #009900;">&#125;</span><span style="color: #000000; font-weight: bold;">else</span><span style="color: #009900;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; Macros.<span style="color: #006633;">error</span><span style="color: #009900;">&#40;</span>view, <span style="color: #0000ff;">&quot;File <span style="color: #000099; font-weight: bold;">\&quot;</span>&quot;</span><span style="color: #339933;">+</span>aFilePath<span style="color: #339933;">+</span><span style="color: #0000ff;">&quot;<span style="color: #000099; font-weight: bold;">\&quot;</span> does not exist!&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; <span style="color: #009900;">&#125;</span><br />
&nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">return</span> retVal<span style="color: #339933;">;</span><br />
<span style="color: #009900;">&#125;</span><br />
<br />
<br />
<br />
<span style="color: #003399;">String</span> getMethodOwner<span style="color: #009900;">&#40;</span><span style="color: #003399;">String</span> functionName, <span style="color: #003399;">String</span> lineWhereItAppears<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span><br />
&nbsp; &nbsp; <span style="color: #003399;">String</span> retVal <span style="color: #339933;">=</span> <span style="color: #000066; font-weight: bold;">null</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; <span style="color: #003399;">String</span> methodRegEx <span style="color: #339933;">=</span> <span style="color: #0000ff;">&quot;((.+)<span style="color: #000099; font-weight: bold;">\\</span>s*<span style="color: #000099; font-weight: bold;">\\</span>.<span style="color: #000099; font-weight: bold;">\\</span>s*)?(&quot;</span><span style="color: #339933;">+</span>functionName<span style="color: #339933;">+</span><span style="color: #0000ff;">&quot;)<span style="color: #000099; font-weight: bold;">\\</span>s*<span style="color: #000099; font-weight: bold;">\\</span>((.*?)<span style="color: #000099; font-weight: bold;">\\</span>)&quot;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; Pattern methodRegPat <span style="color: #339933;">=</span> Pattern.<span style="color: #006633;">compile</span><span style="color: #009900;">&#40;</span>methodRegEx<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; Matcher methodMatcher <span style="color: #339933;">=</span> methodRegPat.<span style="color: #006633;">matcher</span><span style="color: #009900;">&#40;</span>lineWhereItAppears<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">if</span> <span style="color: #009900;">&#40;</span>methodMatcher.<span style="color: #006633;">find</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; retVal <span style="color: #339933;">=</span> methodMatcher.<span style="color: #006633;">group</span><span style="color: #009900;">&#40;</span><span style="color: #cc66cc;">2</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">if</span> <span style="color: #009900;">&#40;</span>retVal <span style="color: #339933;">!=</span> <span style="color: #000066; font-weight: bold;">null</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; retVal <span style="color: #339933;">=</span> retVal.<span style="color: #006633;">trim</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #666666; font-style: italic;">// if using a cast (e.g. &quot;MyClass(event.target).methodToSearchFor();&quot;)...</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #009900;">&#40;</span>retVal.<span style="color: #006633;">length</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">&gt;</span> <span style="color: #cc66cc;">0</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">&amp;&amp;</span> <span style="color: #009900;">&#40;</span>retVal.<span style="color: #006633;">matches</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;.*<span style="color: #000099; font-weight: bold;">\\</span>(.*<span style="color: #000099; font-weight: bold;">\\</span>)$&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; retVal <span style="color: #339933;">=</span> retVal.<span style="color: #006633;">substring</span><span style="color: #009900;">&#40;</span><span style="color: #cc66cc;">0</span>,<span style="color: #009900;">&#40;</span>retVal.<span style="color: #006633;">lastIndexOf</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;(&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #666666; font-style: italic;">// if 'inline'</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; methodRegPat <span style="color: #339933;">=</span> Pattern.<span style="color: #006633;">compile</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;.+<span style="color: #000099; font-weight: bold;">\\</span>b(<span style="color: #000099; font-weight: bold;">\\</span>w+)$&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; methodMatcher <span style="color: #339933;">=</span> methodRegPat.<span style="color: #006633;">matcher</span><span style="color: #009900;">&#40;</span>retVal<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">if</span> <span style="color: #009900;">&#40;</span>methodMatcher.<span style="color: #006633;">find</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span> retVal <span style="color: #339933;">=</span> methodMatcher.<span style="color: #006633;">group</span><span style="color: #009900;">&#40;</span><span style="color: #cc66cc;">1</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">if</span> <span style="color: #009900;">&#40;</span>retVal <span style="color: #339933;">!=</span> <span style="color: #000066; font-weight: bold;">null</span><span style="color: #009900;">&#41;</span> retVal <span style="color: #339933;">=</span> retVal.<span style="color: #006633;">trim</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #666666; font-style: italic;">//Macros.message(view, &quot;method owner variable is '&quot;+retVal+&quot;'&quot;);</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900;">&#125;</span><br />
&nbsp; &nbsp; <span style="color: #009900;">&#125;</span><br />
&nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">return</span> retVal<span style="color: #339933;">;</span><br />
<span style="color: #009900;">&#125;</span><br />
<br />
<span style="color: #666666; font-style: italic;">// /functions - - - - - - - - - - - - - - - - - - - - -</span><br />
<br />
<br />
<br />
<span style="color: #003399;">String</span> foundDocFilePath <span style="color: #339933;">=</span> <span style="color: #000066; font-weight: bold;">null</span><span style="color: #339933;">;</span> <span style="color: #666666; font-style: italic;">// the path to the documentation html file to display</span><br />
<br />
<span style="color: #666666; font-style: italic;">// run search on the word under cursor or the selected text</span><br />
<span style="color: #000000; font-weight: bold;">if</span> <span style="color: #009900;">&#40;</span>textArea.<span style="color: #006633;">selectedText</span> <span style="color: #339933;">==</span> <span style="color: #000066; font-weight: bold;">null</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span><br />
&nbsp; &nbsp; textArea.<span style="color: #006633;">goToPrevCharacter</span><span style="color: #009900;">&#40;</span><span style="color: #000066; font-weight: bold;">false</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; textArea.<span style="color: #006633;">selectWord</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
<span style="color: #009900;">&#125;</span><br />
<span style="color: #003399;">String</span> wordToFind <span style="color: #339933;">=</span> textArea.<span style="color: #006633;">selectedText</span><span style="color: #339933;">;</span><br />
foundDocFilePath <span style="color: #339933;">=</span> searchForDocs<span style="color: #009900;">&#40;</span>wordToFind<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
<br />
<br />
<span style="color: #666666; font-style: italic;">// if nothing found, see if the selection is defined as a variable. </span><br />
<span style="color: #666666; font-style: italic;">// If it is, take variable's type and run a search on that</span><br />
<span style="color: #000000; font-weight: bold;">if</span> <span style="color: #009900;">&#40;</span>foundDocFilePath <span style="color: #339933;">==</span> <span style="color: #000066; font-weight: bold;">null</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span><br />
&nbsp; &nbsp; <span style="color: #003399;">String</span> typeOfVar <span style="color: #339933;">=</span> findTypeOfVarFromFile<span style="color: #009900;">&#40;</span>wordToFind, buffer.<span style="color: #006633;">getPath</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">if</span> <span style="color: #009900;">&#40;</span>typeOfVar <span style="color: #339933;">!=</span> <span style="color: #000066; font-weight: bold;">null</span><span style="color: #009900;">&#41;</span> foundDocFilePath <span style="color: #339933;">=</span> searchForDocs<span style="color: #009900;">&#40;</span>typeOfVar<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
<span style="color: #009900;">&#125;</span><br />
<br />
<br />
<span style="color: #666666; font-style: italic;">// if still nothing found...</span><br />
<span style="color: #000000; font-weight: bold;">if</span> <span style="color: #009900;">&#40;</span>foundDocFilePath <span style="color: #339933;">==</span> <span style="color: #000066; font-weight: bold;">null</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span><br />
&nbsp; &nbsp; <span style="color: #666666; font-style: italic;">// if selection is a function/method name, get its owner variable</span><br />
&nbsp; &nbsp; <span style="color: #003399;">String</span> methodOwnerVar <span style="color: #339933;">=</span> getMethodOwner<span style="color: #009900;">&#40;</span>wordToFind, textArea.<span style="color: #006633;">getLineText</span><span style="color: #009900;">&#40;</span>textArea.<span style="color: #006633;">getCaretLine</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; <br />
&nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">if</span> <span style="color: #009900;">&#40;</span>methodOwnerVar <span style="color: #339933;">!=</span> <span style="color: #000066; font-weight: bold;">null</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #666666; font-style: italic;">// if starts with an uppercase letter, probably a class name -&gt; try that</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">if</span> <span style="color: #009900;">&#40;</span>methodOwnerVar.<span style="color: #006633;">substring</span><span style="color: #009900;">&#40;</span><span style="color: #cc66cc;">0</span>,<span style="color: #cc66cc;">1</span><span style="color: #009900;">&#41;</span>.<span style="color: #006633;">matches</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;[A-Z]&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; foundDocFilePath <span style="color: #339933;">=</span> searchForDocs<span style="color: #009900;">&#40;</span>methodOwnerVar<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900;">&#125;</span><br />
&nbsp; &nbsp; <span style="color: #009900;">&#125;</span><br />
&nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">if</span> <span style="color: #009900;">&#40;</span>foundDocFilePath <span style="color: #339933;">==</span> <span style="color: #000066; font-weight: bold;">null</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">if</span> <span style="color: #009900;">&#40;</span>methodOwnerVar <span style="color: #339933;">==</span> <span style="color: #000066; font-weight: bold;">null</span><span style="color: #009900;">&#41;</span> methodOwnerVar <span style="color: #339933;">==</span> <span style="color: #0000ff;">&quot;this&quot;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #666666; font-style: italic;">// find type of this owner var and if found, search for that class</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #003399;">String</span> typeOfOwnerVar <span style="color: #339933;">=</span> <span style="color: #000066; font-weight: bold;">null</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; typeOfOwnerVar <span style="color: #339933;">=</span> findTypeOfVarFromFile<span style="color: #009900;">&#40;</span>methodOwnerVar, buffer.<span style="color: #006633;">getPath</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #666666; font-style: italic;">//Macros.message(view, &quot;method owner type is '&quot;+typeOfOwnerVar+&quot;'&quot;);</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">if</span> <span style="color: #009900;">&#40;</span>typeOfOwnerVar <span style="color: #339933;">!=</span> <span style="color: #000066; font-weight: bold;">null</span><span style="color: #009900;">&#41;</span> foundDocFilePath <span style="color: #339933;">=</span> searchForDocs<span style="color: #009900;">&#40;</span>typeOfOwnerVar<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; <span style="color: #009900;">&#125;</span><br />
&nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">if</span> <span style="color: #009900;">&#40;</span>foundDocFilePath <span style="color: #339933;">!=</span> <span style="color: #000066; font-weight: bold;">null</span><span style="color: #009900;">&#41;</span> foundDocFilePath <span style="color: #339933;">=</span> foundDocFilePath<span style="color: #339933;">+</span><span style="color: #0000ff;">&quot;#&quot;</span><span style="color: #339933;">+</span>wordToFind<span style="color: #339933;">+</span><span style="color: #0000ff;">&quot;<span style="color: #000099; font-weight: bold;">\\</span><span style="color: #000099; font-weight: bold;">\\</span>(<span style="color: #000099; font-weight: bold;">\\</span><span style="color: #000099; font-weight: bold;">\\</span>)&quot;</span><span style="color: #339933;">;</span><br />
<span style="color: #009900;">&#125;</span><br />
<br />
<br />
<br />
<br />
<span style="color: #666666; font-style: italic;">// if found a doc URL, display it</span><br />
<span style="color: #000000; font-weight: bold;">if</span> <span style="color: #009900;">&#40;</span>foundDocFilePath <span style="color: #339933;">!=</span> <span style="color: #000066; font-weight: bold;">null</span><span style="color: #009900;">&#41;</span> &nbsp; &nbsp;<span style="color: #009900;">&#123;</span><br />
&nbsp; &nbsp; <br />
&nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #339933;">!</span>foundDocFilePath.<span style="color: #006633;">startsWith</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;file://&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span> foundDocFilePath <span style="color: #339933;">=</span> <span style="color: #0000ff;">&quot;file://&quot;</span><span style="color: #339933;">+</span>foundDocFilePath<span style="color: #339933;">;</span><br />
&nbsp; &nbsp; <br />
&nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">if</span> <span style="color: #009900;">&#40;</span>displayInInfoViewer<span style="color: #009900;">&#41;</span> infoviewer.<span style="color: #006633;">InfoViewerPlugin</span>.<span style="color: #006633;">openURL</span><span style="color: #009900;">&#40;</span>view, foundDocFilePath<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">else</span> <span style="color: #009900;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #003399;">Object</span><span style="color: #009900;">&#91;</span><span style="color: #009900;">&#93;</span> mfArgs <span style="color: #339933;">=</span> <span style="color: #009900;">&#123;</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;<span style="color: #000099; font-weight: bold;">\&quot;</span>&quot;</span><span style="color: #339933;">+</span>foundDocFilePath<span style="color: #339933;">+</span><span style="color: #0000ff;">&quot;<span style="color: #000099; font-weight: bold;">\&quot;</span>&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#125;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; commandToRun <span style="color: #339933;">=</span> <span style="color: #003399;">MessageFormat</span>.<span style="color: #006633;">format</span><span style="color: #009900;">&#40;</span>openCommand, mfArgs<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; runInSystemShell<span style="color: #009900;">&#40;</span>view, commandToRun<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">if</span> <span style="color: #009900;">&#40;</span>view.<span style="color: #006633;">getDockableWindowManager</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span>.<span style="color: #006633;">isDockableWindowDocked</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;console&quot;</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">==</span> <span style="color: #000066; font-weight: bold;">true</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">if</span> <span style="color: #009900;">&#40;</span>view.<span style="color: #006633;">getDockableWindowManager</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span>.<span style="color: #006633;">isDockableWindowVisible</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;console&quot;</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">==</span> <span style="color: #000066; font-weight: bold;">true</span><span style="color: #009900;">&#41;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; view.<span style="color: #006633;">getDockableWindowManager</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span>.<span style="color: #006633;">removeDockableWindow</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;console&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900;">&#125;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; <span style="color: #009900;">&#125;</span><br />
&nbsp; &nbsp; <br />
<span style="color: #009900;">&#125;</span><span style="color: #000000; font-weight: bold;">else</span><span style="color: #009900;">&#123;</span><br />
&nbsp; &nbsp; <br />
&nbsp; &nbsp; Macros.<span style="color: #006633;">error</span><span style="color: #009900;">&#40;</span>view, <span style="color: #0000ff;">&quot;Sorry. No Flex documentation found for <span style="color: #000099; font-weight: bold;">\&quot;</span>&quot;</span><span style="color: #339933;">+</span>wordToFind<span style="color: #339933;">+</span><span style="color: #0000ff;">&quot;<span style="color: #000099; font-weight: bold;">\&quot;</span>.&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; <br />
<span style="color: #009900;">&#125;</span><br />
<br />
<br />
<br />
<span style="color: #666666; font-style: italic;">/*<br />
<br />
Macro index data (in DocBook format)<br />
<br />
&nbsp; &lt;listitem&gt;<br />
&nbsp; &nbsp; &lt;para&gt;&lt;filename&gt;Display_Flex_documentation.bsh&lt;/filename&gt;&lt;/para&gt;<br />
&nbsp; &nbsp; &lt;abstract&gt;&lt;para&gt;<br />
&nbsp; &nbsp; &nbsp; Displays documentation about selected class, package or method from Flex language reference<br />
&nbsp; &nbsp; &nbsp; and optionally also other AsDoc sources<br />
&nbsp; &nbsp; &lt;/para&gt;&lt;/abstract&gt;<br />
&nbsp; &lt;/listitem&gt;<br />
<br />
*/</span><br />
<br />
<span style="color: #666666; font-style: italic;">// end Display_Flex_documentation.bsh</span></div></div>
</p>
<p>
As you can see from the settings, the macro can be set to open the documentation html page in either the InfoViewer plugin in jEdit or an external web browser. I prefer to have it open up in the browser, since the formatting and styling of the Flex language reference contribute to the fact that the pages don&#8217;t really work very well in the InfoViewer plugin. <del>The OS X <em>open</em> command is used to make the external browser open up the documentation, which means that if someone would want to use this in Windows or Linux, that part would have to be re-implemented.</del> <em>Update: Now you can simply edit the openCommand variable in the &#8220;settings&#8221; area to change the command that is run in the system shell to open up docs in the browser.</em>
</p>
<p>
Get the script here:
</p>
<p>
<a href="/stuff/jEditMacros/Display_Flex_documentation.bsh">Display_Flex_documentation.bsh</a>
</p>
<p>
<em>Update (October 5, 07): Modified the script so that it can search from any number of different AsDoc sources (which the official Flex language reference is one of)</em>
</p>
<p>
<em>Update (October 8, 07): Modified the script to also find documentation for methods. Made it easier to modify the command that is run in the system shell to open up documentation .html pages in an external browser.</em>
</p>
<p>
<em>Update (October 10, 07): Modified the script to operate on files instead of buffers so that it can also search files that are not currently open.</em></p>
]]></content:encoded>
			<wfw:commentRss>http://hasseg.org/blog/post/98/flex-sdk-language-reference-helper-macro-for-jedit/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>jEdit Macros for Running Compilers</title>
		<link>http://hasseg.org/blog/post/96/jedit-macros-for-running-compilers/</link>
		<comments>http://hasseg.org/blog/post/96/jedit-macros-for-running-compilers/#comments</comments>
		<pubDate>Tue, 25 Sep 2007 18:18:17 +0000</pubDate>
		<dc:creator>Ali Rantakari</dc:creator>
				<category><![CDATA[Flex]]></category>
		<category><![CDATA[jEdit]]></category>
		<category><![CDATA[Programming]]></category>
		<category><![CDATA[Scripts]]></category>

		<guid isPermaLink="false">http://hasseg.org/blog/?p=96</guid>
		<description><![CDATA[I&#8217;ve been using jEdit as my ActionScript 3 editor for a while now. I Like the extension and customization possibilities it gives me, and I&#8217;ve used them to create macros for compiling my Flex applications and then bound them to specific keyboard shortcuts to enable quick access to running the compiler. For a while, I [...]]]></description>
			<content:encoded><![CDATA[<p>
<img align="right" style="padding-left: 5px;" src='http://hasseg.org/blog/wp-content/uploaded/2007/09/compilescriptgrowl.png' alt='compileMxml shell script displays Growl notifications' /> I&#8217;ve been using jEdit as my ActionScript 3 editor for a while now. I Like the extension and customization possibilities it gives me, and I&#8217;ve used them to create macros for compiling my Flex applications and then bound them to specific keyboard shortcuts to enable quick access to running the compiler.
</p>
<p><span id="more-96"></span></p>
<p>
For a while, I had the compiler command and the parameters (i.e. the file to compile) hardcoded in my macro, but recently I changed this to a more reusable solution where you have one macro for selecting the file (&#8220;buffer&#8221; in jEdit lingo) to be compiled and another for actually running the compiler on that file. Then I simply bind keystrokes for both of them. This enables me to easily and quickly run the compiler whenever I want to, and also change the file to be compiled (and, of course, also the compiler used – automatically based on the file extension) if I switch projects.
</p>
<p><h3>Select_file_to_compile.bsh</h3>
<p>First, let&#8217;s take a look at <em>Select_file_to_compile.bsh</em>, which is used to select the file (as you can see, it saves the file path into a jEdit property which the other script will later read):</p>
<div class="codecolorer-container java mac-classic codecolorer-customstyle" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><div class="java codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color: #666666; font-style: italic;">// SETTINGS: --------------------------------------</span><br />
&nbsp; &nbsp; <br />
&nbsp; &nbsp; <span style="color: #666666; font-style: italic;">/* <br />
&nbsp; &nbsp; * set allowed file extensions here: (include leading point)<br />
&nbsp; &nbsp; */</span><br />
&nbsp; &nbsp; allowedExtensions <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> <span style="color: #003399;">String</span><span style="color: #009900;">&#91;</span><span style="color: #009900;">&#93;</span> <span style="color: #009900;">&#123;</span><span style="color: #0000ff;">&quot;.mxml&quot;</span>, <span style="color: #0000ff;">&quot;.java&quot;</span><span style="color: #009900;">&#125;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; <br />
<span style="color: #666666; font-style: italic;">// /settings - - - - - - - - - - - - - - - - - - - </span><br />
<br />
<br />
<span style="color: #666666; font-style: italic;">// Macro implementation begins here: &nbsp;------------</span><br />
<br />
currentBufferPath <span style="color: #339933;">=</span> jEdit.<span style="color: #006633;">getProperty</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;macro.compile_specific_buffer.buffer_path&quot;</span>, <span style="color: #0000ff;">&quot;&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
<br />
allBuffers <span style="color: #339933;">=</span> jEdit.<span style="color: #006633;">getBuffers</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
<br />
mxmlBuffers <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> <span style="color: #003399;">Object</span><span style="color: #009900;">&#91;</span>allBuffers.<span style="color: #006633;">length</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">;</span><br />
<br />
<span style="color: #000066; font-weight: bold;">int</span> currentlySelectedIndex <span style="color: #339933;">=</span> <span style="color: #cc66cc;">0</span><span style="color: #339933;">;</span><br />
<span style="color: #000066; font-weight: bold;">int</span> j <span style="color: #339933;">=</span> <span style="color: #cc66cc;">0</span><span style="color: #339933;">;</span><br />
<span style="color: #000000; font-weight: bold;">for</span> <span style="color: #009900;">&#40;</span><span style="color: #000066; font-weight: bold;">int</span> i <span style="color: #339933;">=</span> <span style="color: #cc66cc;">0</span><span style="color: #339933;">;</span> i <span style="color: #339933;">&lt;</span> allBuffers.<span style="color: #006633;">length</span><span style="color: #339933;">;</span> i<span style="color: #339933;">++</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span><br />
&nbsp; &nbsp; <span style="color: #003399;">Boolean</span> extensionMatch <span style="color: #339933;">=</span> <span style="color: #000066; font-weight: bold;">false</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">for</span> <span style="color: #009900;">&#40;</span><span style="color: #000066; font-weight: bold;">int</span> k <span style="color: #339933;">=</span> <span style="color: #cc66cc;">0</span><span style="color: #339933;">;</span> k <span style="color: #339933;">&lt;</span> allowedExtensions.<span style="color: #006633;">length</span><span style="color: #339933;">;</span> k<span style="color: #339933;">++</span><span style="color: #009900;">&#41;</span> <br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">if</span> <span style="color: #009900;">&#40;</span>allBuffers<span style="color: #009900;">&#91;</span>i<span style="color: #009900;">&#93;</span>.<span style="color: #006633;">getName</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span>.<span style="color: #006633;">endsWith</span><span style="color: #009900;">&#40;</span>allowedExtensions<span style="color: #009900;">&#91;</span>k<span style="color: #009900;">&#93;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span> extensionMatch <span style="color: #339933;">=</span> <span style="color: #000066; font-weight: bold;">true</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; <br />
&nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">if</span> <span style="color: #009900;">&#40;</span>extensionMatch <span style="color: #339933;">==</span> <span style="color: #000066; font-weight: bold;">true</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">if</span> <span style="color: #009900;">&#40;</span>currentBufferPath.<span style="color: #006633;">equals</span><span style="color: #009900;">&#40;</span>allBuffers<span style="color: #009900;">&#91;</span>i<span style="color: #009900;">&#93;</span>.<span style="color: #006633;">getPath</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span> currentlySelectedIndex <span style="color: #339933;">=</span> j<span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; mxmlBuffers<span style="color: #009900;">&#91;</span>j<span style="color: #339933;">++</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">=</span> allBuffers<span style="color: #009900;">&#91;</span>i<span style="color: #009900;">&#93;</span>.<span style="color: #006633;">getPath</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; <span style="color: #009900;">&#125;</span><br />
<span style="color: #009900;">&#125;</span><br />
<br />
<span style="color: #000000; font-weight: bold;">if</span> <span style="color: #009900;">&#40;</span>j <span style="color: #339933;">==</span> <span style="color: #cc66cc;">0</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span><br />
&nbsp; &nbsp; <br />
&nbsp; &nbsp; Macros.<span style="color: #006633;">error</span><span style="color: #009900;">&#40;</span>view, <span style="color: #0000ff;">&quot;Can not find any open buffers with the specified extensions!&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; <br />
<span style="color: #009900;">&#125;</span><span style="color: #000000; font-weight: bold;">else</span><span style="color: #009900;">&#123;</span><br />
&nbsp; &nbsp; <br />
&nbsp; &nbsp; listItems <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> <span style="color: #003399;">Object</span><span style="color: #009900;">&#91;</span>j<span style="color: #009900;">&#93;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">for</span> <span style="color: #009900;">&#40;</span><span style="color: #000066; font-weight: bold;">int</span> i <span style="color: #339933;">=</span> <span style="color: #cc66cc;">0</span><span style="color: #339933;">;</span> i <span style="color: #339933;">&lt;</span> j<span style="color: #339933;">;</span> i<span style="color: #339933;">++</span><span style="color: #009900;">&#41;</span> listItems<span style="color: #009900;">&#91;</span>i<span style="color: #009900;">&#93;</span> <span style="color: #339933;">=</span> mxmlBuffers<span style="color: #009900;">&#91;</span>i<span style="color: #009900;">&#93;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; <br />
&nbsp; &nbsp; result <span style="color: #339933;">=</span> <span style="color: #003399;">JOptionPane</span>.<span style="color: #006633;">showInputDialog</span><span style="color: #009900;">&#40;</span>view,<br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0000ff;">&quot;Choose which file to pass to the compiler the next time you run the compile macro:&quot;</span>,<br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0000ff;">&quot;Select file to compile&quot;</span>,<br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #003399;">JOptionPane</span>.<span style="color: #006633;">QUESTION_MESSAGE</span>,<br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000066; font-weight: bold;">null</span>, listItems, listItems<span style="color: #009900;">&#91;</span>currentlySelectedIndex<span style="color: #009900;">&#93;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>&nbsp; &nbsp; <br />
&nbsp; &nbsp; <br />
&nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">if</span> <span style="color: #009900;">&#40;</span>result <span style="color: #339933;">!=</span> <span style="color: #000066; font-weight: bold;">null</span><span style="color: #009900;">&#41;</span> jEdit.<span style="color: #006633;">setProperty</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;macro.compile_specific_buffer.buffer_path&quot;</span>, result<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; <br />
<span style="color: #009900;">&#125;</span></div></div>
</p>
<p><h3>Compile_previously_selected_file.bsh</h3>
<p>Then there&#8217;s <em>Compile_previously_selected_file.bsh</em> which invokes the compiling process. Notice the <em>displayDockedConsole</em> parameter in the settings – a <em>false</em> value will make sure that the Console plugin will not open up whenever the compiling starts. I Want to keep it closed because I don&#8217;t make this macro call the mxml compiler directly, but instead through a bash shell script (<em>compileMxml.bash</em> – link below) that displays a <a href="http://growl.info/">Growl</a> notification whenever the compiling finishes, telling me whether or not the application was compiled successfully. In case of errors, the notification will be sticky, so that if I leave my computer to compile and then come back later, I&#8217;ll still be able to see it.</p>
<div class="codecolorer-container java mac-classic codecolorer-customstyle" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><div class="java codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color: #666666; font-style: italic;">// SETTINGS: --------------------------------------</span><br />
&nbsp; &nbsp; <br />
&nbsp; &nbsp; <span style="color: #666666; font-style: italic;">/* <br />
&nbsp; &nbsp; * match file extensions and compilers here (no <br />
&nbsp; &nbsp; * trailing space after compiler command):<br />
&nbsp; &nbsp; */</span><br />
&nbsp; &nbsp; compilers <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> <span style="color: #003399;">HashMap</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; compilers.<span style="color: #006633;">put</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;.mxml&quot;</span>, <span style="color: #0000ff;">&quot;/path/to/flex/sdk/bin/mxmlc --file-specs&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; compilers.<span style="color: #006633;">put</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;.java&quot;</span>, <span style="color: #0000ff;">&quot;/path/to/java/sdk/bin/javac &quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; <br />
&nbsp; &nbsp; <br />
&nbsp; &nbsp; <span style="color: #666666; font-style: italic;">/*<br />
&nbsp; &nbsp; * whether or not to display the console when compiling<br />
&nbsp; &nbsp; * (only works if the console is docked)<br />
&nbsp; &nbsp; */</span><br />
&nbsp; &nbsp; displayDockedConsole <span style="color: #339933;">=</span> <span style="color: #000066; font-weight: bold;">false</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; <br />
<span style="color: #666666; font-style: italic;">// /settings - - - - - - - - - - - - - - - - - - - </span><br />
<br />
<br />
<br />
<span style="color: #666666; font-style: italic;">// Macro implementation begins here: &nbsp;------------</span><br />
<br />
<span style="color: #000000; font-weight: bold;">if</span> <span style="color: #009900;">&#40;</span>compilers.<span style="color: #006633;">isEmpty</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span><br />
&nbsp; &nbsp; <br />
&nbsp; &nbsp; Macros.<span style="color: #006633;">error</span><span style="color: #009900;">&#40;</span>view, <span style="color: #0000ff;">&quot;No compilers specified!&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; <br />
<span style="color: #009900;">&#125;</span><span style="color: #000000; font-weight: bold;">else</span><span style="color: #009900;">&#123;</span><br />
&nbsp; &nbsp; <br />
&nbsp; &nbsp; theBufferPath <span style="color: #339933;">=</span> jEdit.<span style="color: #006633;">getProperty</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;macro.compile_specific_buffer.buffer_path&quot;</span>,<span style="color: #0000ff;">&quot;&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; <br />
&nbsp; &nbsp; compilerCommand <span style="color: #339933;">=</span> <span style="color: #0000ff;">&quot;&quot;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; extensions <span style="color: #339933;">=</span> compilers.<span style="color: #006633;">keySet</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span>.<span style="color: #006633;">toArray</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">for</span> <span style="color: #009900;">&#40;</span><span style="color: #000066; font-weight: bold;">int</span> i <span style="color: #339933;">=</span> <span style="color: #cc66cc;">0</span><span style="color: #339933;">;</span> i <span style="color: #339933;">&lt;</span> extensions.<span style="color: #006633;">length</span><span style="color: #339933;">;</span> i<span style="color: #339933;">++</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">if</span> <span style="color: #009900;">&#40;</span>theBufferPath.<span style="color: #006633;">endsWith</span><span style="color: #009900;">&#40;</span>extensions<span style="color: #009900;">&#91;</span>i<span style="color: #009900;">&#93;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span> compilerCommand <span style="color: #339933;">=</span> compilers.<span style="color: #006633;">get</span><span style="color: #009900;">&#40;</span>extensions<span style="color: #009900;">&#91;</span>i<span style="color: #009900;">&#93;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; <span style="color: #009900;">&#125;</span><br />
&nbsp; &nbsp; <br />
&nbsp; &nbsp; <br />
&nbsp; &nbsp; <br />
&nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">if</span> <span style="color: #009900;">&#40;</span>theBufferPath.<span style="color: #006633;">equals</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; Macros.<span style="color: #006633;">error</span><span style="color: #009900;">&#40;</span>view, <span style="color: #0000ff;">&quot;No file has been specified to be compiled! Use the <span style="color: #000099; font-weight: bold;">\&quot;</span>Select_file_to_compile<span style="color: #000099; font-weight: bold;">\&quot;</span> macro to specify it.&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; <span style="color: #009900;">&#125;</span><span style="color: #000000; font-weight: bold;">else</span> <span style="color: #000000; font-weight: bold;">if</span> <span style="color: #009900;">&#40;</span>compilerCommand.<span style="color: #006633;">equals</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; Macros.<span style="color: #006633;">error</span><span style="color: #009900;">&#40;</span>view, <span style="color: #0000ff;">&quot;No compiler set for this file extension! <span style="color: #000099; font-weight: bold;">\n</span>(file path: <span style="color: #000099; font-weight: bold;">\&quot;</span>&quot;</span><span style="color: #339933;">+</span>theBufferPath<span style="color: #339933;">+</span><span style="color: #0000ff;">&quot;<span style="color: #000099; font-weight: bold;">\&quot;</span>)&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; <span style="color: #009900;">&#125;</span><span style="color: #000000; font-weight: bold;">else</span><span style="color: #009900;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; os <span style="color: #339933;">=</span> <span style="color: #003399;">System</span>.<span style="color: #006633;">getProperty</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;os.name&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">if</span><span style="color: #009900;">&#40;</span>os.<span style="color: #006633;">indexOf</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;Windows&quot;</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">!=</span> <span style="color: #339933;">-</span><span style="color: #cc66cc;">1</span><span style="color: #009900;">&#41;</span> path <span style="color: #339933;">=</span> <span style="color: #0000ff;">&quot;<span style="color: #000099; font-weight: bold;">\&quot;</span>&quot;</span> <span style="color: #339933;">+</span> path <span style="color: #339933;">+</span> <span style="color: #0000ff;">&quot;<span style="color: #000099; font-weight: bold;">\&quot;</span>&quot;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; clearConsole<span style="color: #009900;">&#40;</span>view<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; runInSystemShell<span style="color: #009900;">&#40;</span>view, compilerCommand <span style="color: #339933;">+</span> <span style="color: #0000ff;">&quot; &quot;</span> <span style="color: #339933;">+</span> theBufferPath<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">if</span> <span style="color: #009900;">&#40;</span>displayDockedConsole <span style="color: #339933;">==</span> <span style="color: #000066; font-weight: bold;">false</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">if</span> <span style="color: #009900;">&#40;</span>view.<span style="color: #006633;">getDockableWindowManager</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span>.<span style="color: #006633;">isDockableWindowDocked</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;console&quot;</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">==</span> <span style="color: #000066; font-weight: bold;">true</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">if</span> <span style="color: #009900;">&#40;</span>view.<span style="color: #006633;">getDockableWindowManager</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span>.<span style="color: #006633;">isDockableWindowVisible</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;console&quot;</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">==</span> <span style="color: #000066; font-weight: bold;">true</span><span style="color: #009900;">&#41;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; view.<span style="color: #006633;">getDockableWindowManager</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span>.<span style="color: #006633;">removeDockableWindow</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;console&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900;">&#125;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900;">&#125;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; <span style="color: #009900;">&#125;</span><br />
&nbsp; &nbsp; <br />
<span style="color: #009900;">&#125;</span></div></div>
</p>
<p><h3>Download scripts</h3>
<ul>
<li>Get the jEdit macros here: <a href="/stuff/jEditMacros/jEditCompileMacros.zip">jEditCompileMacros.zip</a></li>
<p>Install them by saving them to jEdit&#8217;s macros directory. Then you can go to &#8220;utilities&#8221; -> &#8220;global options&#8221; -> &#8220;shortcuts&#8221; -> &#8220;macros&#8221; to set the keyboard shortcuts. In Mac OS X, the jEdit macros folder can be found here:</p>
<div class="codecolorer-container text mac-classic codecolorer-customstyle" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><div class="text codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">~/.jEdit/macros/</div></div>
<p>Please also note that you need the Console plugin for jEdit for this to work. Go to &#8220;plugins&#8221; -> &#8220;plugin manager&#8221; -> &#8220;install&#8221; to get it.</p>
<li>Get the mxml compiler shell script (+ the icon images used in the Growl notifications it displays) here: <a href="/stuff/compileMxmlScript/compileMxml.zip">compileMxml.zip</a></li>
</ul>
]]></content:encoded>
			<wfw:commentRss>http://hasseg.org/blog/post/96/jedit-macros-for-running-compilers/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>OS X Mouse Wheel Support for Flex 2 Applications</title>
		<link>http://hasseg.org/blog/post/3/os-x-mouse-wheel-support-for-flex-2-applications/</link>
		<comments>http://hasseg.org/blog/post/3/os-x-mouse-wheel-support-for-flex-2-applications/#comments</comments>
		<pubDate>Fri, 06 Jul 2007 10:33:31 +0000</pubDate>
		<dc:creator>Ali Rantakari</dc:creator>
				<category><![CDATA[ActionScript 3]]></category>
		<category><![CDATA[Flex]]></category>
		<category><![CDATA[Mac]]></category>
		<category><![CDATA[Programming]]></category>

		<guid isPermaLink="false">http://hasseg.org/blog/?p=3</guid>
		<description><![CDATA[Note: This version of this solution is deprecated. I&#8217;ve made a separate post about the new version, which you can find here. In my current job I have been programming user interfaces for applications that display networks of data (as in nodes, links etc.) with the Adobe Flex framework, and the UI paradigm I have [...]]]></description>
			<content:encoded><![CDATA[<div class="note-red"><strong>Note:</strong> This version of this solution is deprecated. I&#8217;ve made a separate post about the new version, <a href="?p=138">which you can find here</a>.</div>
<p></p>
<p>In my current job I have been programming user interfaces for applications that display networks of data (as in nodes, links etc.) with the Adobe Flex framework, and the UI paradigm I have been utilizing is a kind of a <a href="http://en.wikipedia.org/wiki/ZUI">Zoomable User Interface (ZUI)</a>. The idea there is to enable the user to view and manipulate objects on a two-dimensional plane, and navigate around that plane by zooming and panning.</p>
<p>Now, the easiest way (at least for me) to control the zooming is to use the mouse wheel. Mouse wheel support for Flex is implemented by registering an event listener of type <em>MouseEvent.MOUSE_WHEEL</em> with the DisplayObject that would dispatch the event. Sadly, <u>mouse wheel support is not available in the Mac OS X version of Flash Player</u>. This prompted me to create a custom solution, as my main computer is a MacBook and I would like to be able to test the mouse wheel navigation with my development machine.</p>
<p>
<em><b>Update</b>: The javascript now works with more browsers than just Firefox 2 and Safari 2. I Tested it, in addition to those two, with Opera 9, Camino 1.5 and Omniweb 5.5, and it seems to work in all of them now.</em>
</p>
<p>
<em><b>Update #2</b>: Changed the javascript code to also work with Safari 3 beta. When using it, small movements with the wheel do not invoke any action, so you&#8217;ll have to roll it a bit further to make the app respond.</em>
</p>
<p>
<em><b>Update #3</b>: Added statement about licensing the code under the MIT License as per request of Philip Flip Kromer</em>
</p>
<p>
<em><b>Update #4 (feb 8, 08)</b>: If you&#8217;re looking for AS3 (not Flex) OS X mouse wheel support, check out <a href="http://blog.pixelbreaker.com/flash/as30-mousewheel-on-mac-os-x/">PixelBreaker.com</a>.</em>
</p>
<p>
<em><b>Update #5 (feb 12, 08)</b>: Fljot sent me <a href="/stuff/FlexOSXMouseWheel/OSXMouseWheelSupportForFlex2andAS3.rar">a version of this that works also in non-Flex AS3 projects</a>. He also fixed some issues in the code related to the automatic registration of listening objects. You can <a href="http://fljot.livejournal.com/">find him here</a>.</em>
</p>
<p><span id="more-3"></span></p>
<p>The solution has been tested with <del>Firefox 2 and Safari 2</del> Firefox 2, Safari 2, Opera 9, Camino 1.5 and Omniweb 5.5, and it is based on two main elements:</p>
<ul>
<li>JavaScript code that catches mouse events and sends their details through a function call to the Flash app using the <a href="http://livedocs.adobe.com/flex/2/langref/flash/external/ExternalInterface.html">ExternalInterface</a></li>
<li>An ActionScript 3 singleton class <em>ExternalMouseWheelSupport</em> that registers an ExternalInterface callback for the function call and makes objects that are under the mouse cursor dispatch MouseEvents of type <em>MouseEvent.MOUSE_WHEEL</em></li>
</ul>
<p><strong><u>JavaScript:</u></strong></p>
<p>
Just include the <a href="http://hasseg.org/stuff/FlexOSXMouseWheel/osxmousewheel.js">osxmousewheel.js</a> file in your HTML and specify the ids/names of your flash object element and the div element that contains the flash object:</p>
<div class="codecolorer-container javascript mac-classic codecolorer-customstyle" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><div class="javascript codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color: #339933;">&lt;</span>script type<span style="color: #339933;">=</span><span style="color: #3366CC;">&quot;text/javascript&quot;</span><span style="color: #339933;">&gt;</span> <br />
&nbsp; &nbsp; <span style="color: #003366; font-weight: bold;">var</span> mw_flashMovieId <span style="color: #339933;">=</span> <span style="color: #3366CC;">&quot;flashMovie&quot;</span><span style="color: #339933;">;</span> <span style="color: #006600; font-style: italic;">// the id/name of your flash app's HTML DOM element &nbsp; &nbsp; </span><br />
&nbsp; &nbsp; <span style="color: #003366; font-weight: bold;">var</span> mw_flashContainerId <span style="color: #339933;">=</span> <span style="color: #3366CC;">&quot;flashContainerDiv&quot;</span><span style="color: #339933;">;</span> <span style="color: #006600; font-style: italic;">// the id/name of the flash element's surrounding div element &nbsp;</span><br />
<span style="color: #339933;">&lt;/</span>script<span style="color: #339933;">&gt;</span><br />
&lt;script src=&quot;./osxmousewheel.js&quot; type=&quot;text/javascript&quot;&gt;&lt;/script&gt;</div></div>
</p>
<p><strong><u>ActionScript:</u></strong></p>
<p>
The singleton has to be created first, and that can be done by getting a reference to the <em>instance</em> property in at least one place:</p>
<div class="codecolorer-container actionscript mac-classic codecolorer-customstyle" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><div class="actionscript codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color: #0066CC;">import</span> org.<span style="color: #006600;">hasseg</span>.<span style="color: #006600;">externalMouseWheel</span>.<span style="color: #66cc66;">*</span>;<br />
<span style="color: #0066CC;">private</span> <span style="color: #000000; font-weight: bold;">var</span> _mwSupport:ExternalMouseWheelSupport = ExternalMouseWheelSupport.<span style="color: #006600;">instance</span>;</div></div>
<p>Then, all objects that you want to have the OS X mouse wheel support enabled for have to be registered with the ExternalMouseWheelSupport class. This can be done in two ways:</p>
<ol>
<li><u>Manually:</u></li>
<p>This is the more foolproof way. First make sure that the <em>registerAutomatically</em> property is set to <em>false</em> (it is <em>true</em> by default):</p>
<div class="codecolorer-container actionscript mac-classic codecolorer-customstyle" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><div class="actionscript codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">ExternalMouseWheelSupport.<span style="color: #006600;">registerAutomatically</span> = <span style="color: #000000; font-weight: bold;">false</span>;</div></div>
<p>Then just register the objects one by one:</p>
<div class="codecolorer-container actionscript mac-classic codecolorer-customstyle" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><div class="actionscript codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">_mwSupport.<span style="color: #006600;">registerObject</span><span style="color: #66cc66;">&#40;</span>myBox<span style="color: #66cc66;">&#41;</span>;</div></div>
<p>or several at a time:</p>
<div class="codecolorer-container actionscript mac-classic codecolorer-customstyle" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><div class="actionscript codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">_mwSupport.<span style="color: #006600;">registerObjects</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#91;</span>myBox, myButton, mySlider<span style="color: #66cc66;">&#93;</span><span style="color: #66cc66;">&#41;</span>;</div></div>
<li><u>Automatically:</u></li>
<p>This is the easier, but more bug-prone way. Simply make sure that the <em>registerAutomatically</em> property is set to <em>true</em> (it is <em>true</em> by default, so you actually don&#8217;t even need to do this):</p>
<div class="codecolorer-container actionscript mac-classic codecolorer-customstyle" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><div class="actionscript codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">ExternalMouseWheelSupport.<span style="color: #006600;">registerAutomatically</span> = <span style="color: #000000; font-weight: bold;">true</span>;</div></div>
<p>After that, all InteractiveObjects on the stage should dispatch mouse events, so you can normally attach event listeners to them and do whatever you want in them:</p>
<div class="codecolorer-container actionscript mac-classic codecolorer-customstyle" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><div class="actionscript codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">myBox.<span style="color: #006600;">addEventListener</span><span style="color: #66cc66;">&#40;</span>MouseEvent.<span style="color: #006600;">MOUSE_WHEEL</span>, <span style="color: #000000; font-weight: bold;">function</span><span style="color: #66cc66;">&#40;</span>event:MouseEvent<span style="color: #66cc66;">&#41;</span>:<span style="color: #0066CC;">void</span> <span style="color: #66cc66;">&#123;</span><br />
&nbsp; &nbsp; t.<span style="color: #0066CC;">text</span> = <span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">&quot;Mouse wheel delta: &quot;</span>+event.<span style="color: #006600;">delta</span><span style="color: #66cc66;">&#41;</span>;<br />
<span style="color: #66cc66;">&#125;</span><span style="color: #66cc66;">&#41;</span>;</div></div>
</ol>
<p>
The code could probably use some debugging and optimization, but it seems to work well if you&#8217;re not doing anything too fancy. If you take it and make any fixes, please let me know! ;)</p>
<p><a href="/stuff/FlexOSXMouseWheel/example.html">A working example.</a><br />
<br />
<a href="/stuff/FlexOSXMouseWheel/OSXMouseWheelSupportForFlex2.zip">The source code for the example.</a><br />
<br />
<a href="/stuff/FlexOSXMouseWheel/asdoc-output/index.html">The AsDoc-generated API Documentation for the support library</a></p>
<p>
This code is distributed under the <a href="http://hasseg.org/stuff/license/MIT_License.txt">MIT License</a>.</p>
]]></content:encoded>
			<wfw:commentRss>http://hasseg.org/blog/post/3/os-x-mouse-wheel-support-for-flex-2-applications/feed/</wfw:commentRss>
		<slash:comments>44</slash:comments>
		</item>
	</channel>
</rss>

