<?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>W.J. Warren</title>
	<atom:link href="http://blog.ansuz.nl/index.php/feed/" rel="self" type="application/rss+xml" />
	<link>http://blog.ansuz.nl</link>
	<description>Flash Developer</description>
	<lastBuildDate>Wed, 14 Mar 2012 20:56:21 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
		<item>
		<title>Ant-Contrib for loop error</title>
		<link>http://blog.ansuz.nl/index.php/2012/03/14/ant-contrib-for-loop-error-2/</link>
		<comments>http://blog.ansuz.nl/index.php/2012/03/14/ant-contrib-for-loop-error-2/#comments</comments>
		<pubDate>Wed, 14 Mar 2012 20:56:21 +0000</pubDate>
		<dc:creator>Wijnand</dc:creator>
				<category><![CDATA[Random]]></category>
		<category><![CDATA[ant]]></category>
		<category><![CDATA[ant-contrib]]></category>
		<category><![CDATA[contrib]]></category>

		<guid isPermaLink="false">http://blog.ansuz.nl/?p=326</guid>
		<description><![CDATA[When trying to use Ant-Contrib for loops today, I ran into the error below: BUILD FAILED C:\Projects\...\ant\build.xml:200: Problem: failed to create task or type for Cause: The name is undefined. Action: Check the spelling. Action: Check that any custom tasks/types &#8230; <a href="http://blog.ansuz.nl/index.php/2012/03/14/ant-contrib-for-loop-error-2/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>When trying to use <a href="http://ant-contrib.sourceforge.net/tasks/tasks/for.html" target="_blank">Ant-Contrib for loops</a> today, I ran into the error below:</p>
<blockquote><p>BUILD FAILED<br />
C:\Projects\...\ant\build.xml:200: Problem: failed to create task or type for<br />
Cause: The name is undefined.<br />
Action: Check the spelling.<br />
Action: Check that any custom tasks/types have been declared.<br />
Action: Check that any &lt;presetdef&gt;/&lt;macrodef&gt; declarations have taken place.</p></blockquote>
<p>To fix the error I had to update the Ant-Contrib taskdef resource path from using "antcontrib.properties" to use "antlib.xml" in my Ant build file.</p>
<div class="igBar"><span id="lcode-2"><a href="#" onclick="javascript:showPlainTxt('code-2'); return false;">PLAIN TEXT</a></span></div>
<div class="syntax_hilite"><span class="langName">CODE:</span>
<div id="code-2">
<div class="code">
<ol>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#FF9933; font-style:italic;">// Remove this line</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&lt;taskdef resource=<span style="color:#CC0000;">"net/sf/antcontrib/antcontrib.properties&gt;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#CC0000;">// And replace with this one</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#CC0000;">&lt;taskdef resource="</span>net/sf/antcontrib/antlib.<span style="">xml</span><span style="color:#CC0000;">"&gt; </span></div>
</li>
</ol>
</div>
</div>
</div>
<p></p>
<p>According to the <a href="http://ant-contrib.sourceforge.net/" target="_blank">Ant-Contrib</a> manual (found in [Ant-Contrib install dir]/docs/manual/index.html) you need to use the "antcontrib.properties" file when you want <a href="http://ant-contrib.sourceforge.net/" target="_blank">Ant-Contrib</a> to run with Ant Version 1.5. They even place a warning saying:</p>
<blockquote><p>Keep in mind that some tasks will not be available to you , such as the &lt;for&gt; task</p></blockquote>
<p>The confusing part is that on the <a href="http://ant-contrib.sourceforge.net/#install" target="_blank">project page</a> they tell you to use the "antcontrib.properties" file.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.ansuz.nl/index.php/2012/03/14/ant-contrib-for-loop-error-2/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Recording the microphone</title>
		<link>http://blog.ansuz.nl/index.php/2012/03/04/recording-the-microphone/</link>
		<comments>http://blog.ansuz.nl/index.php/2012/03/04/recording-the-microphone/#comments</comments>
		<pubDate>Sun, 04 Mar 2012 18:53:25 +0000</pubDate>
		<dc:creator>Wijnand</dc:creator>
				<category><![CDATA[ActionScript 3.0]]></category>
		<category><![CDATA[audio]]></category>
		<category><![CDATA[microphone]]></category>

		<guid isPermaLink="false">http://blog.ansuz.nl/?p=291</guid>
		<description><![CDATA[Recording the microphone using AS3 is quite easy. Actually, storing the data or compressing it and sending it to a server is where it gets complicated. Normally, a Google search helps a lot when trying to find good information, but &#8230; <a href="http://blog.ansuz.nl/index.php/2012/03/04/recording-the-microphone/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>Recording the microphone using AS3 is quite easy. Actually, storing the data or compressing it and sending it to a server is where it gets complicated. Normally, a Google search helps a lot when trying to find good information, but on this particular subject there seems to be a lot of misinformation. There are also a lot of libraries and / or frameworks available, but so far they didn't really do what I wanted to do or did it in a far too complicated way. I've provided a list of audio libraries I tried out at the bottom.</p>
<p><strong>Clearing things up</strong></p>
<p><strong></strong>When you record data from the <a href="http://help.adobe.com/en_US/FlashPlatform/reference/actionscript/3/flash/media/Microphone.html" target="_blank">microphone</a> using <a href="http://help.adobe.com/en_US/FlashPlatform/reference/actionscript/3/flash/media/Microphone.html#event:sampleData" target="_blank">SampleDataEvents</a>, the actual data is (part of a) 32-bit floating point (Big Endian) 44.1 kHz mono <a href="http://en.wikipedia.org/wiki/Pulse_code_modulation" target="_blank">PCM</a> audio stream (assuming that you left the rate of the Microphone at its default of 44). To store the microphone input, all you need to do is append this data to a buffer.</p>
<p>To play back the microphone input you can use the <a href="http://help.adobe.com/en_US/FlashPlatform/reference/actionscript/3/flash/media/Sound.html" target="_blank">Sound class</a>. The Sound class can only deal with a 32-bit floating point 44.1 kHz stereo PCM audio stream as input. Lucky for us, we're almost there, we just need to convert mono into stereo. As you can see in the example below, creating (fake) stereo out of a mono signal is a matter of writing each sample twice.</p>
<p>The documentation for the Sound class shows an example of how to merge several Sounds into one using the <a href="http://help.adobe.com/en_US/FlashPlatform/reference/actionscript/3/flash/media/Sound.html#extract%28%29" target="_blank">extract method</a>. We can apply the same technique to play back our ByteArray using the Sound class:</p>
<div class="igBar"><span id="lcode-4"><a href="#" onclick="javascript:showPlainTxt('code-4'); return false;">PLAIN TEXT</a></span></div>
<div class="syntax_hilite"><span class="langName">CODE:</span>
<div id="code-4">
<div class="code">
<ol>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#FF9933; font-style:italic;">// The buffer where we stored the microphone input.</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">var playbackBuffer:ByteArray;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#FF9933; font-style:italic;">// The number of channels the buffer contains,</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#FF9933; font-style:italic;">// 1 means mono, 2 means stereo.</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">var channels:int = <span style="color:#800000;color:#800000;">1</span>;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">var outputSound:Sound = new Sound<span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#006600; font-weight:bold;">&#41;</span>;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">outputSound.<span style="">addEventListener</span><span style="color:#006600; font-weight:bold;">&#40;</span>SampleDataEvent.<span style="">SAMPLE_DATA</span>,</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">outputSampleDataHandler<span style="color:#006600; font-weight:bold;">&#41;</span>;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">outputChannel = outputSound.<span style="">play</span><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#006600; font-weight:bold;">&#41;</span>;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">private function outputSampleDataHandler<span style="color:#006600; font-weight:bold;">&#40;</span>event:SampleDataEvent<span style="color:#006600; font-weight:bold;">&#41;</span>:void <span style="color:#006600; font-weight:bold;">&#123;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; for <span style="color:#006600; font-weight:bold;">&#40;</span>var i:int = <span style="color:#800000;color:#800000;">0</span>; i &lt;<span style="color:#800000;color:#800000;">8192</span> &amp;&amp;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; playbackBuffer.<span style="">bytesAvailable</span>&gt; <span style="color:#800000;color:#800000;">2</span>; i++<span style="color:#006600; font-weight:bold;">&#41;</span> <span style="color:#006600; font-weight:bold;">&#123;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; var sample:Number = playbackBuffer.<span style="">readFloat</span><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#006600; font-weight:bold;">&#41;</span>;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; event.<span style="">data</span>.<span style="">writeFloat</span><span style="color:#006600; font-weight:bold;">&#40;</span>sample<span style="color:#006600; font-weight:bold;">&#41;</span>;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color:#FF9933; font-style:italic;">// Fake stereo as dual mono when the</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color:#FF9933; font-style:italic;">// original data is only 1 channel.</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; if<span style="color:#006600; font-weight:bold;">&#40;</span>channels&gt; <span style="color:#800000;color:#800000;">2</span><span style="color:#006600; font-weight:bold;">&#41;</span> <span style="color:#006600; font-weight:bold;">&#123;</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; event.<span style="">data</span>.<span style="">writeFloat</span><span style="color:#006600; font-weight:bold;">&#40;</span>sample<span style="color:#006600; font-weight:bold;">&#41;</span>;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color:#006600; font-weight:bold;">&#125;</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color:#006600; font-weight:bold;">&#125;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#006600; font-weight:bold;">&#125;</span> </div>
</li>
</ol>
</div>
</div>
</div>
<p></p>
<p>The above seems simple enough, but when you want to save the data to a file, things get complicated. First you need to choose a file format in which to store the output. Secondly, if you want to reduce the amount of data to be saved, you need to choose a codec to compress the audio stream. When I was experimenting with MP3 encoding of my recorded data, I found out that the codec required the stream input to be a 16-bit signed integer with a sampling rate of 44.1 kHz. When you get into this territory, it helps to read up a bit about the techniques behind digital audio. I'll try to summarize some of the most useful things I learned.</p>
<p><strong>Pulse-code modulation (PCM)</strong></p>
<p><a href="http://en.wikipedia.org/wiki/Pulse_code_modulation" target="_blank">Pulse-code modulation</a> is a way of representing analog audio signal on a digital system by sampling the signal at a fixed interval. See 1) in the <a href="http://blog.ansuz.nl/tests/audio/pcm.png" target="_blank">image I created to explain some PCM examples</a>.</p>
<p>By keeping the same playback frequency, but adding more samples (using some form of interpolation), you slow down playback / lower the pitch (blue curve). The opposite is also true, remove samples and playback will speed up / the pitch is higher (red curve). See 2) in the <a href="http://blog.ansuz.nl/tests/audio/pcm.png" target="_blank">PCM examples image</a>.</p>
<p>If you multiply or divide the each sample by a fixed value, you increase or decrease the signal strength (green curve). See 3) in the <a href="http://blog.ansuz.nl/tests/audio/pcm.png" target="_blank">PCM examples image</a>. Keep in mind that multiplying or dividing could result in <a href="http://en.wikipedia.org/wiki/Clipping_%28audio%29" target="_blank">clipping</a> or complete cancellation of the signal if you overflow or underflow the bit depth precision.</p>
<p><strong>Sample rate conversion</strong></p>
<p>The <a href="http://en.wikipedia.org/wiki/Sampling_rate" target="_blank">sample rate</a> defines how many samples are taken of the analogue sound per second and is expressed in Hertz, for example, CDs have a sample rate of 44.1 kHz. The higher the sample rate, the better the quality. Other typical sample rates are 8, 11.025, 22.05 and 48 kHz.</p>
<p>There are two types of <a href="http://en.wikipedia.org/wiki/Sample_rate_conversion" target="_blank">sample rate conversion</a>, there is <a href="http://en.wikipedia.org/wiki/Upsampling" target="_blank">upsampling</a> and there is <a href="http://en.wikipedia.org/wiki/Downsampling" target="_blank">downsampling</a>.</p>
<p>It is usually easier (whether you are upsampling or downsampling) to first upsample (using <a href="http://en.wikipedia.org/wiki/Linear_interpolation" target="_blank">linear interpolation</a>) to the <a href="http://en.wikipedia.org/wiki/Least_common_multiple" target="_blank">least common multiple</a> (LCM) and then downsample to the required sample rate.</p>
<p>Generally speaking when you downsample an audio signal you can get away with duplicating a sample when upsampling to the LCM, most of the data will be dropped anyway as you downsample to the required sample rate.</p>
<p>Since sample rate conversion is quite CPU intensive, there are some shortcuts you can take to convert to a certain sample rate from another. Say you want to convert 44.1 kHz into 8 kHz, it seems a bit redundant to first upsample to 3528000 Hz (which is the LCM), and then downsample to 8 kHz. What you could do instead, is alternate between using every 5th and 6th sample (since 44.1 / 8 is roughly 5.5).</p>
<p><strong>Bit depth conversion</strong></p>
<p>The <a href="http://en.wikipedia.org/wiki/Audio_bit_depth" target="_blank">bit depth</a> determines granularity of a single sample, the higher the bit depth, the more accurate the sound can be represented. CDs have a bit depth of 16-bit, other typical bit depths are 8, 24 and 32.</p>
<p>Usually 8-bit audio streams are using unsigned integers, 16-bit ones are using signed integers and 32-bit streams use signed floating point. Knowing this it is quite straightforward to convert from one bit depth to the other, it's a matter of multiplication.</p>
<p><em>Note:</em> You may need to do some additional checks to make sure you aren't overflowing the available bits when doing the conversion.</p>
<p>When you understand the theory I just talked about, it becomes a lot easier to write the tools you need to convert audio from one bit rate to the other as well as changing between sample rates. It also gave me some ideas about some filters to implement, like a <a href="http://en.wikipedia.org/wiki/Audio_normalization" target="_blank">normalization</a> filter. To help you get started I've included some tips and references below.</p>
<p><strong>Tips</strong></p>
<ul>
<li>The Microphone.rate property accepts values of 44, 22, 11 and 8. These values actually represent 44100, 22050, 11025 and 8000 Hz.</li>
<li>The <a href="http://code.google.com/p/micrecorder/source/browse/trunk/MicRecorder/src/org/bytearray/micrecorder/encoder/WaveEncoder.as" target="_blank">WaveEncoder class</a> of the <a href="http://www.bytearray.org/?p=1858" target="_blank">MicRecorder library</a> comes in quite handy when you want to save your recorded audio. Keep in mind that the encode method expects the passed in data to be 32-bit and will convert it to 16-bit on the fly. This tripped me up a couple of times as I passed in a 16-bit audio stream and was surprised to find out that the saved WAV file just produced a lot of white noise. On my copy of this class, I added an additional check to the create method, to make sure that the 16-bit space wasn't being overflown when converting and multiplying by a _volume (multiplier) value.</li>
<li>When you want to output your recorded audio, make sure to keep the <a href="http://en.wikipedia.org/wiki/Endianness" target="_blank">Endianness </a>of your ByteArrays to Little Endian. I wondered countless times why playback of my ByteArray resulted in just noise, only to find out that I had forgotten about the Endianness of it.</li>
<li>Forget about the <a href="http://help.adobe.com/en_US/FlashPlatform/beta/reference/actionscript/3/flash/media/Sound.html#loadCompressedDataFromByteArray()" target="_blank">loadCompressedDataFromByteArray</a> and <a href="http://help.adobe.com/en_US/FlashPlatform/beta/reference/actionscript/3/flash/media/Sound.html#loadPCMFromByteArray()" target="_blank">loadPCMFromByteArray</a> methods in the Sound class for Flash Player 11. They just don't work, you'll get a sound playing, but the last set of bytes seem to loop forever when the audio stream should be finished.</li>
<li>If you want to see how the sound you produced actually looks like, you may want to download sofware like <a href="http://audacity.sourceforge.net/" target="_blank">Audacity</a>. This tool can give you a visual representation of the wave form as well as a lot of information about the file that you opened. When you open a raw audio stream, you can also flick the settings around to figure out what sampling rate and bit depth the stream is using.</li>
</ul>
<p><strong>Further reading</strong></p>
<ul>
<li><a href="http://en.wikipedia.org/wiki/Pulse_code_modulation" target="_blank">PCM</a></li>
<li><a href="http://en.wikipedia.org/wiki/Analog-to-digital_converter" target="_blank">ADC</a> / <a href="http://en.wikipedia.org/wiki/Digital-to-analog_converter" target="_blank">DAC</a></li>
<li><a href="https://ccrma.stanford.edu/courses/422/projects/WaveFormat/" target="_blank">WAV file format</a></li>
<li><a href="http://forums.adobe.com/thread/659903" target="_blank">AS3 Microphone Endianness</a></li>
</ul>
<p><strong>AS3 audio libraries</strong></p>
<ul>
<li><a href="https://github.com/kikko/Shine-MP3-Encoder-on-AS3-Alchemy" target="_blank">Shine MP3 encoder on Alchemy</a></li>
<li><a href="http://www.libspark.org/browser/as3/sazameki/trunk/src/" target="_blank">Sazameki</a> - audio manipulating library</li>
<li><a href="http://www.bytearray.org/?p=1858" target="_blank">MicRecorder</a>, <a href="http://code.google.com/p/micrecorder/source/browse/#svn%2Ftrunk%2FMicRecorder" target="_blank">Source</a></li>
</ul>
]]></content:encoded>
			<wfw:commentRss>http://blog.ansuz.nl/index.php/2012/03/04/recording-the-microphone/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Alchemy on Windows7</title>
		<link>http://blog.ansuz.nl/index.php/2012/02/28/alchemy-on-windows7/</link>
		<comments>http://blog.ansuz.nl/index.php/2012/02/28/alchemy-on-windows7/#comments</comments>
		<pubDate>Tue, 28 Feb 2012 15:28:03 +0000</pubDate>
		<dc:creator>Wijnand</dc:creator>
				<category><![CDATA[ActionScript 3.0]]></category>
		<category><![CDATA[Flex]]></category>
		<category><![CDATA[alchemy]]></category>
		<category><![CDATA[c]]></category>
		<category><![CDATA[gcc]]></category>

		<guid isPermaLink="false">http://blog.ansuz.nl/?p=287</guid>
		<description><![CDATA[Installing Adobe Alchemy on Windows7 wasn't as straightforward as the Adobe Labs site made me believe. The following error would keep on showing when I tried to run the example: $ gcc stringecho.c -O3 -Wall -swc -o stringecho.swc llvm-gcc.exe: error &#8230; <a href="http://blog.ansuz.nl/index.php/2012/02/28/alchemy-on-windows7/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>Installing Adobe Alchemy on Windows7 wasn't as straightforward as the Adobe Labs site made me believe.</p>
<p>The following error would keep on showing when I tried to run the example:</p>
<blockquote><p>$ gcc stringecho.c -O3 -Wall -swc -o stringecho.swc<br />
llvm-gcc.exe: error while loading shared libraries: ? ...</p></blockquote>
<p>I finally got it to work by using the steps below:</p>
<ol>
<li>Install the <a href="http://www.covergraph.com/blog/?p=367" target="_blank">Alchemy Repack</a>, from <a href="http://www.covergraph.com" target="_blank">www.covergraph.com</a> in a temporary directory (I just want to copy some of the files).</li>
<li>Download and install <a href="http://labs.adobe.com/technologies/alchemy/" target="_blank">Alchemy</a> from the Adobe website, as per their <a href="http://labs.adobe.com/wiki/index.php/Alchemy:Documentation:Getting_Started" target="_blank">instructions</a>.</li>
<li>Copy the "achacks", "avm2-libc", "bin" and "flashlibs" folders from your "Alchemy Repack" installation folder.</li>
<li>Uninstall / Delete Alchemy Repack</li>
<li>Good to go! <img src='http://blog.ansuz.nl/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </li>
<li>(Optional:) Set the "CYGWIN=nodosfilewarning" environment variable option to avoid Cygwin warnings about MS-Dos style paths. (Unfortunately, this doesn't work for me, even though "echo ${CYGWIN}" prints "nodosfilewarning".)</li>
</ol>
<p>Note: If you already have Cygwin installed, you can install additional packages by running setup.exe again.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.ansuz.nl/index.php/2012/02/28/alchemy-on-windows7/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Sound from ByteArray</title>
		<link>http://blog.ansuz.nl/index.php/2012/02/20/sound-from-bytearray/</link>
		<comments>http://blog.ansuz.nl/index.php/2012/02/20/sound-from-bytearray/#comments</comments>
		<pubDate>Mon, 20 Feb 2012 17:57:22 +0000</pubDate>
		<dc:creator>Wijnand</dc:creator>
				<category><![CDATA[ActionScript 3.0]]></category>
		<category><![CDATA[Air]]></category>
		<category><![CDATA[Flex]]></category>
		<category><![CDATA[as3]]></category>
		<category><![CDATA[bytearray]]></category>
		<category><![CDATA[mp3]]></category>
		<category><![CDATA[sound]]></category>

		<guid isPermaLink="false">http://blog.ansuz.nl/?p=285</guid>
		<description><![CDATA[While writing a quick test application to record microphone input and playing that same recording, I found out that playing back a ByteArray directly using the Sound class wasn't possible. Luckily a solution is never far away when doing a &#8230; <a href="http://blog.ansuz.nl/index.php/2012/02/20/sound-from-bytearray/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>While writing a quick test application to record microphone input and playing that same recording, I found out that playing back a ByteArray directly using the Sound class wasn't possible. Luckily a solution is never far away when doing a Google search and it turns out that FlexibleFactory has a good solution: <a href="http://www.flexiblefactory.co.uk/flexible/?p=46" target="_blank">the MP3FileReferenceLoader lib</a>. With a bit of tweaking you can pass in a ByteArray directly and don't need to rely on a FileReference.</p>
<p>Good news though! As per Flash Player 11, the following 2 methods have been added to the (native) Sound class that can be used to achieve the same behaviour:</p>
<ul>
<li>Sound.loadCompressedDataFromByteArray(bytes:ByteArray, bytesLength:uint)</li>
<li>Sound.loadPCMFromByteArray(bytes:ByteArray, samples:uint, format:String = "float", stereo:Boolean = true, sampleRate:Number = 44100.0)</li>
</ul>
]]></content:encoded>
			<wfw:commentRss>http://blog.ansuz.nl/index.php/2012/02/20/sound-from-bytearray/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Eclipse Color Theme</title>
		<link>http://blog.ansuz.nl/index.php/2012/02/16/eclipse-color-theme/</link>
		<comments>http://blog.ansuz.nl/index.php/2012/02/16/eclipse-color-theme/#comments</comments>
		<pubDate>Thu, 16 Feb 2012 11:39:56 +0000</pubDate>
		<dc:creator>Wijnand</dc:creator>
				<category><![CDATA[Random]]></category>
		<category><![CDATA[color]]></category>
		<category><![CDATA[color-scheme]]></category>
		<category><![CDATA[colour]]></category>
		<category><![CDATA[Eclipse]]></category>
		<category><![CDATA[FDT]]></category>
		<category><![CDATA[scheme]]></category>
		<category><![CDATA[theme]]></category>

		<guid isPermaLink="false">http://blog.ansuz.nl/?p=282</guid>
		<description><![CDATA[Seems like people have caught on to the need of being able to create and manage themes in Eclipse. The Eclipse Color Theme plugin does this very well and also works like a charm with FDT. Unfortunately this is still &#8230; <a href="http://blog.ansuz.nl/index.php/2012/02/16/eclipse-color-theme/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>Seems like people have caught on to the need of being able to create and manage themes in Eclipse. The <a href="http://marketplace.eclipse.org/content/eclipse-color-theme" target="_blank">Eclipse Color Theme</a> plugin does this very well and also works like a charm with FDT.</p>
<p>Unfortunately this is still only changing colors of the text editor and not the whole IDE.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.ansuz.nl/index.php/2012/02/16/eclipse-color-theme/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>&#8220;java -fullversion&#8221; triggers ProgressEvent.STANDARD_ERROR_DATA in AIR</title>
		<link>http://blog.ansuz.nl/index.php/2011/03/22/java-fullversion-triggers-progresseventstandard_error_data-in-air/</link>
		<comments>http://blog.ansuz.nl/index.php/2011/03/22/java-fullversion-triggers-progresseventstandard_error_data-in-air/#comments</comments>
		<pubDate>Tue, 22 Mar 2011 16:43:23 +0000</pubDate>
		<dc:creator>Wijnand</dc:creator>
				<category><![CDATA[ActionScript 3.0]]></category>
		<category><![CDATA[Air]]></category>
		<category><![CDATA[Java]]></category>

		<guid isPermaLink="false">http://blog.ansuz.nl/?p=276</guid>
		<description><![CDATA[I'm building an AIR app and am using Java to offload some heavy duty work to keep Flash responsive. I want to make sure the end user has a version of Java installed the is compatible with the Jar I &#8230; <a href="http://blog.ansuz.nl/index.php/2011/03/22/java-fullversion-triggers-progresseventstandard_error_data-in-air/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>I'm building an AIR app and am using Java to offload some heavy duty work to keep Flash responsive. I want to make sure the end user has a version of Java installed the is compatible with the Jar I ship with my AIR app. To do so I use the following (pseudo) code below:</p>
<div class="igBar"><span id="lcode-6"><a href="#" onclick="javascript:showPlainTxt('code-6'); return false;">PLAIN TEXT</a></span></div>
<div class="syntax_hilite"><span class="langName">CODE:</span>
<div id="code-6">
<div class="code">
<ol>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">var args:Vector.&amp;lt;String&amp;gt; = new Vector.&amp;lt;String&amp;gt;<span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#006600; font-weight:bold;">&#41;</span>;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">args.<span style="">push</span><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#CC0000;">"-fullversion"</span><span style="color:#006600; font-weight:bold;">&#41;</span>;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">var info:NativeProcessStartupInfo = new NativeProcessStartupInfo<span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#006600; font-weight:bold;">&#41;</span>;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">info.<span style="">executable</span> = javaLocation;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">info.<span style="">arguments</span> = args;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">javaProcess = new NativeProcess<span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#006600; font-weight:bold;">&#41;</span>;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">javaProcess.<span style="">addEventListener</span><span style="color:#006600; font-weight:bold;">&#40;</span>ProgressEvent.<span style="">STANDARD_OUTPUT_DATA</span>, versionOutputHandler<span style="color:#006600; font-weight:bold;">&#41;</span>;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#FF9933; font-style:italic;">// Fun fact: -fullversion output is considered error data! :s</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">javaProcess.<span style="">addEventListener</span><span style="color:#006600; font-weight:bold;">&#40;</span>ProgressEvent.<span style="">STANDARD_ERROR_DATA</span>, versionOutputHandler<span style="color:#006600; font-weight:bold;">&#41;</span>;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">javaProcess.<span style="">addEventListener</span><span style="color:#006600; font-weight:bold;">&#40;</span>NativeProcessExitEvent.<span style="">EXIT</span>, versionExitHandler<span style="color:#006600; font-weight:bold;">&#41;</span>;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">javaProcess.<span style="">addEventListener</span><span style="color:#006600; font-weight:bold;">&#40;</span>IOErrorEvent.<span style="">STANDARD_OUTPUT_IO_ERROR</span>, versionErrorHandler<span style="color:#006600; font-weight:bold;">&#41;</span>;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">javaProcess.<span style="">addEventListener</span><span style="color:#006600; font-weight:bold;">&#40;</span>IOErrorEvent.<span style="">STANDARD_ERROR_IO_ERROR</span>, versionErrorHandler<span style="color:#006600; font-weight:bold;">&#41;</span>;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">javaProcess.<span style="">start</span><span style="color:#006600; font-weight:bold;">&#40;</span>info<span style="color:#006600; font-weight:bold;">&#41;</span>; </div>
</li>
</ol>
</div>
</div>
</div>
<p></p>
<p>To my surprise the result of the call to "java -fullversion" is send to the standard error stream and thus triggering the <a href="http://help.adobe.com/en_US/FlashPlatform/reference/actionscript/3/flash/desktop/NativeProcess.html#event:standardErrorData" target="_blank">ProgressEvent.STANDARD_ERROR_DATA</a> to be fired.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.ansuz.nl/index.php/2011/03/22/java-fullversion-triggers-progresseventstandard_error_data-in-air/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Don&#8217;t forget to instantiate Strings</title>
		<link>http://blog.ansuz.nl/index.php/2011/03/01/dont-forget-to-instantiate-strings/</link>
		<comments>http://blog.ansuz.nl/index.php/2011/03/01/dont-forget-to-instantiate-strings/#comments</comments>
		<pubDate>Tue, 01 Mar 2011 16:48:16 +0000</pubDate>
		<dc:creator>Wijnand</dc:creator>
				<category><![CDATA[ActionScript 3.0]]></category>
		<category><![CDATA[String]]></category>
		<category><![CDATA[wtf]]></category>

		<guid isPermaLink="false">http://blog.ansuz.nl/?p=273</guid>
		<description><![CDATA[Small wtf moment today. I forgot to instantiate / give a String variable a default value. After appending the string and tracing it, "null" was the first part that showed, see below: PLAIN TEXT CODE: var test:String; test += "Test &#8230; <a href="http://blog.ansuz.nl/index.php/2011/03/01/dont-forget-to-instantiate-strings/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>Small wtf moment today. I forgot to instantiate / give a String variable a default value. After appending the string and tracing it, "null" was the first part that showed, see below:</p>
<div class="igBar"><span id="lcode-9"><a href="#" onclick="javascript:showPlainTxt('code-9'); return false;">PLAIN TEXT</a></span></div>
<div class="syntax_hilite"><span class="langName">CODE:</span>
<div id="code-9">
<div class="code">
<ol>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">var test:String;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">test += <span style="color:#CC0000;">"Test 1, 2, 3, 4..."</span>;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">trace<span style="color:#006600; font-weight:bold;">&#40;</span>test<span style="color:#006600; font-weight:bold;">&#41;</span>;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#FF9933; font-style:italic;">// output: &quot;nullTest 1, 2, 3, 4...&quot; </span></div>
</li>
</ol>
</div>
</div>
</div>
<p></p>
<p>Fix:</p>
<div class="igBar"><span id="lcode-10"><a href="#" onclick="javascript:showPlainTxt('code-10'); return false;">PLAIN TEXT</a></span></div>
<div class="syntax_hilite"><span class="langName">CODE:</span>
<div id="code-10">
<div class="code">
<ol>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">var test:String = <span style="color:#CC0000;">""</span>; </div>
</li>
</ol>
</div>
</div>
</div>
<p></p>
<p>Oops! <img src='http://blog.ansuz.nl/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
]]></content:encoded>
			<wfw:commentRss>http://blog.ansuz.nl/index.php/2011/03/01/dont-forget-to-instantiate-strings/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Flex FTP Abort</title>
		<link>http://blog.ansuz.nl/index.php/2011/02/11/flex-ftp-abort/</link>
		<comments>http://blog.ansuz.nl/index.php/2011/02/11/flex-ftp-abort/#comments</comments>
		<pubDate>Fri, 11 Feb 2011 13:42:28 +0000</pubDate>
		<dc:creator>Wijnand</dc:creator>
				<category><![CDATA[ActionScript 3.0]]></category>
		<category><![CDATA[Flex]]></category>
		<category><![CDATA[flex ftp]]></category>
		<category><![CDATA[FlexFTP]]></category>

		<guid isPermaLink="false">http://blog.ansuz.nl/?p=264</guid>
		<description><![CDATA[To properly close a transfer to the FTP server, you need to send an Abort command (see http://www.w3.org/Protocols/rfc959/4_FileTransfer.html (ABORT) ). Flex FTP doesn't support this so I added some functionality to be able to send an abort. First I added &#8230; <a href="http://blog.ansuz.nl/index.php/2011/02/11/flex-ftp-abort/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>To properly close a transfer to the FTP server, you need to send an Abort command (see <a href="http://www.w3.org/Protocols/rfc959/4_FileTransfer.html" target="_blank">http://www.w3.org/Protocols/rfc959/4_FileTransfer.html</a> (ABORT) ). <a href="http://projects.maliboo.pl/FlexFTP/" target="_blank">Flex FTP</a> doesn't support this so I added some functionality to be able to send an abort.</p>
<p>First I added the Abort command to the Commands class:</p>
<div class="igBar"><span id="lcode-16"><a href="#" onclick="javascript:showPlainTxt('code-16'); return false;">PLAIN TEXT</a></span></div>
<div class="syntax_hilite"><span class="langName">CODE:</span>
<div id="code-16">
<div class="code">
<ol>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">public static const ABOR:String = <span style="color:#CC0000;">"ABOR"</span>; </div>
</li>
</ol>
</div>
</div>
</div>
<p></p>
<p>After that I added a new invoker to the invokers package, <a href="http://ansuz.nl/toys/randomcode/AbortInv.as" target="_blank">AbortInv</a>.</p>
<p>The FTPInvoker class required a new public method to support the Abort command, which can be overridden by the specific implementations. In FTPInvoker I added an abort method like this:</p>
<div class="igBar"><span id="lcode-17"><a href="#" onclick="javascript:showPlainTxt('code-17'); return false;">PLAIN TEXT</a></span></div>
<div class="syntax_hilite"><span class="langName">CODE:</span>
<div id="code-17">
<div class="code">
<ol>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#008000;">/**</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#008000;">* Stops this Invoker from executing.</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#008000;">*/</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">public function abort<span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#006600; font-weight:bold;">&#41;</span>:void <span style="color:#006600; font-weight:bold;">&#123;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#FF9933; font-style:italic;">// Some Invokers just don't need to do anything.</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">finalize<span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#006600; font-weight:bold;">&#41;</span>;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#006600; font-weight:bold;">&#125;</span> </div>
</li>
</ol>
</div>
</div>
</div>
<p></p>
<p>There was only one invoker where I had to override the abort method to get things working correctly and that was the UploadInv class. Here I added the following code:</p>
<div class="igBar"><span id="lcode-18"><a href="#" onclick="javascript:showPlainTxt('code-18'); return false;">PLAIN TEXT</a></span></div>
<div class="syntax_hilite"><span class="langName">CODE:</span>
<div id="code-18">
<div class="code">
<ol>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#008000;">/**</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#008000;">* @inheritDoc</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#008000;">*/</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">override public function abort<span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#006600; font-weight:bold;">&#41;</span>:void <span style="color:#006600; font-weight:bold;">&#123;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">super.<span style="">abort</span><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#006600; font-weight:bold;">&#41;</span>;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">if<span style="color:#006600; font-weight:bold;">&#40;</span>interval<span style="color:#006600; font-weight:bold;">&#41;</span> clearInterval<span style="color:#006600; font-weight:bold;">&#40;</span>interval<span style="color:#006600; font-weight:bold;">&#41;</span>;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">if<span style="color:#006600; font-weight:bold;">&#40;</span>sourceFile<span style="color:#006600; font-weight:bold;">&#41;</span> sourceFile.<span style="">close</span><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#006600; font-weight:bold;">&#41;</span>;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">if<span style="color:#006600; font-weight:bold;">&#40;</span>passiveSocket &amp;amp;&amp;amp; passiveSocket.<span style="">connected</span><span style="color:#006600; font-weight:bold;">&#41;</span> passiveSocket.<span style="">close</span><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#006600; font-weight:bold;">&#41;</span>;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#006600; font-weight:bold;">&#125;</span> </div>
</li>
</ol>
</div>
</div>
</div>
<p></p>
<p>After that it was a matter of updating the FTPClient class with an abort method to get the circle complete.</p>
<div class="igBar"><span id="lcode-19"><a href="#" onclick="javascript:showPlainTxt('code-19'); return false;">PLAIN TEXT</a></span></div>
<div class="syntax_hilite"><span class="langName">CODE:</span>
<div id="code-19">
<div class="code">
<ol>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#008000;">/**</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#008000;">* Aborts the previous FTP command.</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#008000;">*/</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">public function abort<span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#006600; font-weight:bold;">&#41;</span>:void <span style="color:#006600; font-weight:bold;">&#123;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">if<span style="color:#006600; font-weight:bold;">&#40;</span>currentProcess<span style="color:#006600; font-weight:bold;">&#41;</span> <span style="color:#006600; font-weight:bold;">&#123;</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">if<span style="color:#006600; font-weight:bold;">&#40;</span>currentProcess is UploadInv<span style="color:#006600; font-weight:bold;">&#41;</span> <span style="color:#006600; font-weight:bold;">&#123;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">swallowNextResponse = true;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#006600; font-weight:bold;">&#125;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">currentProcess.<span style="">abort</span><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#006600; font-weight:bold;">&#41;</span>;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">currentProcess = null;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#006600; font-weight:bold;">&#125;</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">invoke<span style="color:#006600; font-weight:bold;">&#40;</span> new AbortInv<span style="color:#006600; font-weight:bold;">&#40;</span>this<span style="color:#006600; font-weight:bold;">&#41;</span> <span style="color:#006600; font-weight:bold;">&#41;</span>;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#006600; font-weight:bold;">&#125;</span> </div>
</li>
</ol>
</div>
</div>
</div>
<p></p>
<p>Unfortunately I also had to update handleData method in the FTPClient class a little bit, because aborting an upload would result into 2 (or more) resonses at once from the FTP server.<br />
My handleData method now looks like this:</p>
<div class="igBar"><span id="lcode-20"><a href="#" onclick="javascript:showPlainTxt('code-20'); return false;">PLAIN TEXT</a></span></div>
<div class="syntax_hilite"><span class="langName">CODE:</span>
<div id="code-20">
<div class="code">
<ol>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">private function handleData <span style="color:#006600; font-weight:bold;">&#40;</span>pEvt:ProgressEvent<span style="color:#006600; font-weight:bold;">&#41;</span>:void</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#006600; font-weight:bold;">&#123;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">processing = false;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">var response:String = ctrlSocket.<span style="">readUTFBytes</span><span style="color:#006600; font-weight:bold;">&#40;</span>ctrlSocket.<span style="">bytesAvailable</span><span style="color:#006600; font-weight:bold;">&#41;</span>;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">var responseList:Array = response.<span style="">split</span><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#CC0000;">"<span style="color:#000099; font-weight:bold;">\n</span>"</span><span style="color:#006600; font-weight:bold;">&#41;</span>;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#FF9933; font-style:italic;">// Apparently we always get a linebreak with a response...</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">responseList.<span style="">pop</span><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#006600; font-weight:bold;">&#41;</span>;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">var eventList:Array = new Array<span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#006600; font-weight:bold;">&#41;</span>;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">var evt:FTPEvent;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">for<span style="color:#006600; font-weight:bold;">&#40;</span>var i:int = <span style="color:#800000;color:#800000;">0</span>; i &amp;lt;responseList.<span style="">length</span>; i++<span style="color:#006600; font-weight:bold;">&#41;</span> <span style="color:#006600; font-weight:bold;">&#123;</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">evt = new FTPEvent<span style="color:#006600; font-weight:bold;">&#40;</span>FTPEvent.<span style="">RESPONSE</span><span style="color:#006600; font-weight:bold;">&#41;</span>;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">evt.<span style="">response</span> = FTPResponse.<span style="">parseResponse</span><span style="color:#006600; font-weight:bold;">&#40;</span>responseList<span style="color:#006600; font-weight:bold;">&#91;</span>i<span style="color:#006600; font-weight:bold;">&#93;</span><span style="color:#006600; font-weight:bold;">&#41;</span>;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">eventList.<span style="">push</span><span style="color:#006600; font-weight:bold;">&#40;</span>evt<span style="color:#006600; font-weight:bold;">&#41;</span>;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">if <span style="color:#006600; font-weight:bold;">&#40;</span>FTPClient.<span style="">DEBUG</span><span style="color:#006600; font-weight:bold;">&#41;</span> trace<span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#CC0000;">"-&amp;gt;"</span> + evt.<span style="">response</span>.<span style="">code</span>+<span style="color:#CC0000;">" "</span>+evt.<span style="">response</span>.<span style="">message</span><span style="color:#006600; font-weight:bold;">&#41;</span>;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#006600; font-weight:bold;">&#125;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">if<span style="color:#006600; font-weight:bold;">&#40;</span>swallowNextResponse<span style="color:#006600; font-weight:bold;">&#41;</span> <span style="color:#006600; font-weight:bold;">&#123;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">if <span style="color:#006600; font-weight:bold;">&#40;</span>FTPClient.<span style="">DEBUG</span><span style="color:#006600; font-weight:bold;">&#41;</span> trace<span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#CC0000;">" - ignoring this response..."</span><span style="color:#006600; font-weight:bold;">&#41;</span>;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">swallowNextResponse = false;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">responseList.<span style="">shift</span><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#006600; font-weight:bold;">&#41;</span>;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#006600; font-weight:bold;">&#125;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">if<span style="color:#006600; font-weight:bold;">&#40;</span>responseList.<span style="">length</span>&amp;gt; <span style="color:#800000;color:#800000;">0</span><span style="color:#006600; font-weight:bold;">&#41;</span> <span style="color:#006600; font-weight:bold;">&#123;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">for<span style="color:#006600; font-weight:bold;">&#40;</span>var k:int = <span style="color:#800000;color:#800000;">0</span>; k &amp;lt;responseList.<span style="">length</span>; k++<span style="color:#006600; font-weight:bold;">&#41;</span> <span style="color:#006600; font-weight:bold;">&#123;</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">dispatchEvent<span style="color:#006600; font-weight:bold;">&#40;</span>eventList<span style="color:#006600; font-weight:bold;">&#91;</span>k<span style="color:#006600; font-weight:bold;">&#93;</span><span style="color:#006600; font-weight:bold;">&#41;</span>;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#006600; font-weight:bold;">&#125;</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#006600; font-weight:bold;">&#125;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#006600; font-weight:bold;">&#125;</span> </div>
</li>
</ol>
</div>
</div>
</div>
<p></p>
<p><strong>Links</strong></p>
<ul>
<li><a href="http://projects.maliboo.pl/FlexFTP/" target="_blank">Flex FTP</a></li>
<li><a href="http://ansuz.nl/toys/randomcode/AbortInv.as" target="_blank">AbortInv class</a></li>
<li><a href="http://www.w3.org/Protocols/rfc959/4_FileTransfer.html" target="_blank">FTP spec</a></li>
</ul>
]]></content:encoded>
			<wfw:commentRss>http://blog.ansuz.nl/index.php/2011/02/11/flex-ftp-abort/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Flex + Java = Frankenstein?</title>
		<link>http://blog.ansuz.nl/index.php/2011/02/08/flex-java-frankenstein/</link>
		<comments>http://blog.ansuz.nl/index.php/2011/02/08/flex-java-frankenstein/#comments</comments>
		<pubDate>Tue, 08 Feb 2011 14:00:41 +0000</pubDate>
		<dc:creator>Wijnand</dc:creator>
				<category><![CDATA[ActionScript 3.0]]></category>
		<category><![CDATA[Air]]></category>
		<category><![CDATA[Flex]]></category>
		<category><![CDATA[Java]]></category>

		<guid isPermaLink="false">http://blog.ansuz.nl/?p=260</guid>
		<description><![CDATA[Lately I've been working on a small upload tool in Flex/AIR. To verify that an upload has succeeded, I created a hash (md5) of the entire file and sent that to the backend for verification. The AS3CoreLib contains a nice &#8230; <a href="http://blog.ansuz.nl/index.php/2011/02/08/flex-java-frankenstein/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>Lately I've been working on a small upload tool in Flex/AIR.<br />
To verify that an upload has succeeded, I created a hash (md5) of the entire file and sent that to the backend for verification. The <a href="https://github.com/mikechambers/as3corelib" target="_blank">AS3CoreLib</a> contains a nice MD5 class, MD5Stream, but it's much too slow for creating a checksum of files.</p>
<p>Actually, it's so slow that when I was uploading a 5+ MB file the application would slow down so much that the upload speed dropped to a third of the speed without feeding the MD5Stream data during uploading.<br />
Luckily, with AIR 2.0 <a href="http://help.adobe.com/en_US/FlashPlatform/beta/reference/actionscript/3/flash/desktop/NativeProcess.html" target="_blank">NativeProcess</a> has been introduced, it made it much easier to "outsource" complicated calculation to a process that can deal with that much better, i.e. Java.</p>
<p>The nice thing about Java is that it's cross-platform just as AIR, and these days many people will have the JRE installed.Â  So first of all, I wrote a small Java class that would print out an MD5 hash of a file based on the path that I passed. I jarred the class and added it to my AIR project.<br />
The second step was to call my Java class instead of the AS3 MD5Stream class. This is surprisingly easy. The NativeProcess documentation comes with a pretty clear example and <a href="http://www.riaspace.com/" target="_blank">Piotr Walczyszyn</a> has created a small framework, <a href="http://www.riaspace.com/2010/01/flerry-flex-java-bridge-for-adobe-air-2-0/" target="_blank">Flerry</a>, to let Flex talk to Java and vice versa.</p>
<p>Looking at how Flerry is built will give you some more insight on how to deal with NativeProcess.<br />
For my application, I only use the <a href="http://code.google.com/p/flerry/source/browse/trunk/flerry/src-as3/net/riaspace/flerry/BaseStartupInfoProvider.as" target="_blank">BaseStartupInfoProvider</a> class from Flerry to find where Java is installed on the user's machine. After that I set up all event listeners as per the NativeProcess documentation and call NativeProcess.start() with a NativeProcessStartupInfo as passed in parameter.<br />
Now my uploads are fast again and I can generate a checksum in a fraction of the time I could before.</p>
<p>There are unfortunately some downsides to this approach. You have to deploy your AIR application as <a href="http://help.adobe.com/en_US/air/build/WS789ea67d3e73a8b22388411123785d839c-8000.html">native installer</a> to be able to use the NativeProcess class. So instead of having one AIR file, you'll end up with four native installers (.exe, .dmg, .deb, .rpm). On the plus side, you can create the native installers from an AIR file without needing to resign the application.<br />
Another downside is that now I'm relying on two runtimes being installed on the end user's machine, AIR and Java.<br />
My final thought is that now that I am outsourcing some calculations to Java, why not built the whole thing in Java? Then again, building a decent UI can take ages using Java. To me, my application feels like I'm creating a bit of a Frankenstein.</p>
<p>All in all I'm glad I now have a fast way to generate a checksum and my uploads aren't slowed down by it any more.</p>
<p>Links:</p>
<ul>
<li><a href="http://help.adobe.com/en_US/FlashPlatform/beta/reference/actionscript/3/flash/#desktop/NativeProcess.html" target="_blank">NativeProcess</a></li>
<li><a href="http://help.adobe.com/en_US/air/build/WS789ea67d3e73a8b22388411123785d839c-8000.html">Creating a native installer</a></li>
<li><a href="http://www.riaspace.com/2010/01/flerry-flex-java-bridge-for-adobe-air-2-0/" target="_blank">Flerry</a></li>
<li><a href="http://code.google.com/p/flerry/" target="_blank">Flerry source code</a></li>
</ul>
]]></content:encoded>
			<wfw:commentRss>http://blog.ansuz.nl/index.php/2011/02/08/flex-java-frankenstein/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Flex FTP EPSV support</title>
		<link>http://blog.ansuz.nl/index.php/2011/02/07/flex-ftp-epsv-support/</link>
		<comments>http://blog.ansuz.nl/index.php/2011/02/07/flex-ftp-epsv-support/#comments</comments>
		<pubDate>Mon, 07 Feb 2011 14:26:59 +0000</pubDate>
		<dc:creator>Wijnand</dc:creator>
				<category><![CDATA[ActionScript 3.0]]></category>
		<category><![CDATA[Flex]]></category>
		<category><![CDATA[flex ftp]]></category>
		<category><![CDATA[FlexFTP]]></category>

		<guid isPermaLink="false">http://blog.ansuz.nl/?p=252</guid>
		<description><![CDATA[Still working with Flex FTP and this time I was missing EPSV support. EPSV is roughly the same as PASV, exect that you only get a port number to connect to back and not an IP address. You can read &#8230; <a href="http://blog.ansuz.nl/index.php/2011/02/07/flex-ftp-epsv-support/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>Still working with <a href="http://maliboo.pl/projects/FlexFTP/" target="_blank">Flex FTP</a> and this time I was missing EPSV support. EPSV is roughly the same as PASV, exect that you only get a port number to connect to back and not an IP address. You can read up on <a href="http://www.rfc-archive.org/getrfc.php?rfc=2428" target="_blank">RFC 2428 "FTP Extensions for IPv6 and NATs"</a> if you want more details.</p>
<p>The first thing I did to add support for EPSV in Flex FTP is adding a response to the Responses class.</p>
<div class="igBar"><span id="lcode-27"><a href="#" onclick="javascript:showPlainTxt('code-27'); return false;">PLAIN TEXT</a></span></div>
<div class="syntax_hilite"><span class="langName">CODE:</span>
<div id="code-27">
<div class="code">
<ol>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">public static const ENTERING_EPSV:int = <span style="color:#800000;color:#800000;">229</span>; <span style="color:#FF9933; font-style:italic;">//Entering Extended Passive Mode. </span></div>
</li>
</ol>
</div>
</div>
</div>
<p></p>
<p>Second was the commands class, where I added the following line:</p>
<div class="igBar"><span id="lcode-28"><a href="#" onclick="javascript:showPlainTxt('code-28'); return false;">PLAIN TEXT</a></span></div>
<div class="syntax_hilite"><span class="langName">CODE:</span>
<div id="code-28">
<div class="code">
<ol>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">public static const EPSV:String = <span style="color:#CC0000;">"EPSV"</span>; </div>
</li>
</ol>
</div>
</div>
</div>
<p></p>
<p>Then I added an extra argument to the FTPClient class' constructor that will indicate whether or not to use ESPV.</p>
<div class="igBar"><span id="lcode-29"><a href="#" onclick="javascript:showPlainTxt('code-29'); return false;">PLAIN TEXT</a></span></div>
<div class="syntax_hilite"><span class="langName">CODE:</span>
<div id="code-29">
<div class="code">
<ol>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">public function FTPClient <span style="color:#006600; font-weight:bold;">&#40;</span>host:String=<span style="color:#CC0000;">""</span>, port:int=<span style="color:#800000;color:#800000;">21</span>, useEpsv:Boolean = false<span style="color:#006600; font-weight:bold;">&#41;</span> </div>
</li>
</ol>
</div>
</div>
</div>
<p>
I store the value internally and use a getter method to determine if an Invoker class (i.e ListInv) needs to use EPSV.</p>
<p>Based on the client epsv setting any invoker can be updated to send the EPSV command instead of the PASV command when needed, i.e. my implementation of ListInv's startSequence method:</p>
<div class="igBar"><span id="lcode-30"><a href="#" onclick="javascript:showPlainTxt('code-30'); return false;">PLAIN TEXT</a></span></div>
<div class="syntax_hilite"><span class="langName">CODE:</span>
<div id="code-30">
<div class="code">
<ol>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">override protected function startSequence <span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#006600; font-weight:bold;">&#41;</span>:void <span style="color:#006600; font-weight:bold;">&#123;</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">if<span style="color:#006600; font-weight:bold;">&#40;</span>client.<span style="">useEpsv</span><span style="color:#006600; font-weight:bold;">&#41;</span> <span style="color:#006600; font-weight:bold;">&#123;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">sendCommand<span style="color:#006600; font-weight:bold;">&#40;</span>new FTPCommand<span style="color:#006600; font-weight:bold;">&#40;</span>Commands.<span style="">EPSV</span><span style="color:#006600; font-weight:bold;">&#41;</span><span style="color:#006600; font-weight:bold;">&#41;</span>;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#006600; font-weight:bold;">&#125;</span> else <span style="color:#006600; font-weight:bold;">&#123;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">sendCommand<span style="color:#006600; font-weight:bold;">&#40;</span>new FTPCommand<span style="color:#006600; font-weight:bold;">&#40;</span>Commands.<span style="">PASV</span><span style="color:#006600; font-weight:bold;">&#41;</span><span style="color:#006600; font-weight:bold;">&#41;</span>;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#006600; font-weight:bold;">&#125;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#006600; font-weight:bold;">&#125;</span> </div>
</li>
</ol>
</div>
</div>
</div>
<p></p>
<p>I also update the responseHandler method in ListInv to include the following case:</p>
<div class="igBar"><span id="lcode-31"><a href="#" onclick="javascript:showPlainTxt('code-31'); return false;">PLAIN TEXT</a></span></div>
<div class="syntax_hilite"><span class="langName">CODE:</span>
<div id="code-31">
<div class="code">
<ol>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">case Responses.<span style="">ENTERING_EPSV</span>:</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">passiveSocket =Â Â Â  PassiveSocketInfo.<span style="">createPassiveSocket</span><span style="color:#006600; font-weight:bold;">&#40;</span>evt.<span style="">response</span>.<span style="">message</span>,</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">handlePassiveConnect,</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">handleListing, ioErrorHandler,</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">null, true, client.<span style="">hostname</span><span style="color:#006600; font-weight:bold;">&#41;</span>;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">break; </div>
</li>
</ol>
</div>
</div>
</div>
<p></p>
<p>On top of that I made some tweaks to the PassiveSocketInfo class.<br />
The parseFromResponse method now looks like this:</p>
<div class="igBar"><span id="lcode-32"><a href="#" onclick="javascript:showPlainTxt('code-32'); return false;">PLAIN TEXT</a></span></div>
<div class="syntax_hilite"><span class="langName">CODE:</span>
<div id="code-32">
<div class="code">
<ol>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">public static function parseFromResponse <span style="color:#006600; font-weight:bold;">&#40;</span>pasvResponse:String, usingEpsv:Boolean = false, hostName:String = <span style="color:#CC0000;">""</span><span style="color:#006600; font-weight:bold;">&#41;</span> <img src='http://blog.ansuz.nl/wp-includes/images/smilies/icon_razz.gif' alt=':P' class='wp-smiley' /> assiveSocketInfo <span style="color:#006600; font-weight:bold;">&#123;</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">var host:String;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">var port:int;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">if <span style="color:#006600; font-weight:bold;">&#40;</span>usingEpsv<span style="color:#006600; font-weight:bold;">&#41;</span> <span style="color:#006600; font-weight:bold;">&#123;</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">host = hostName;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">port = pasvResponse.<span style="">match</span><span style="color:#006600; font-weight:bold;">&#40;</span>/\d+/<span style="color:#006600; font-weight:bold;">&#41;</span><span style="color:#006600; font-weight:bold;">&#91;</span><span style="color:#800000;color:#800000;">0</span><span style="color:#006600; font-weight:bold;">&#93;</span>;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#006600; font-weight:bold;">&#125;</span> else <span style="color:#006600; font-weight:bold;">&#123;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">var match:Array = pasvResponse.<span style="">match</span><span style="color:#006600; font-weight:bold;">&#40;</span>/<span style="color:#006600; font-weight:bold;">&#40;</span>\d<span style="color:#006600; font-weight:bold;">&#123;</span><span style="color:#800000;color:#800000;">1</span>,<span style="color:#800000;color:#800000;">3</span><span style="color:#006600; font-weight:bold;">&#125;</span>,<span style="color:#006600; font-weight:bold;">&#41;</span><span style="color:#006600; font-weight:bold;">&#123;</span><span style="color:#800000;color:#800000;">5</span><span style="color:#006600; font-weight:bold;">&#125;</span>\d<span style="color:#006600; font-weight:bold;">&#123;</span><span style="color:#800000;color:#800000;">1</span>,<span style="color:#800000;color:#800000;">3</span><span style="color:#006600; font-weight:bold;">&#125;</span>/<span style="color:#006600; font-weight:bold;">&#41;</span>;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">if <span style="color:#006600; font-weight:bold;">&#40;</span>match == null<span style="color:#006600; font-weight:bold;">&#41;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">throw new Error<span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#CC0000;">"Error parsing passive port! (Response: "</span>+pasvResponse+<span style="color:#CC0000;">")"</span><span style="color:#006600; font-weight:bold;">&#41;</span>;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">var data:Array = match<span style="color:#006600; font-weight:bold;">&#91;</span><span style="color:#800000;color:#800000;">0</span><span style="color:#006600; font-weight:bold;">&#93;</span>.<span style="">split</span><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#CC0000;">","</span><span style="color:#006600; font-weight:bold;">&#41;</span>;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">host = data.<span style="">slice</span><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#800000;color:#800000;">0</span>,<span style="color:#800000;color:#800000;">4</span><span style="color:#006600; font-weight:bold;">&#41;</span>.<span style="">join</span><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#CC0000;">"."</span><span style="color:#006600; font-weight:bold;">&#41;</span>;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">port = parseInt<span style="color:#006600; font-weight:bold;">&#40;</span>data<span style="color:#006600; font-weight:bold;">&#91;</span><span style="color:#800000;color:#800000;">4</span><span style="color:#006600; font-weight:bold;">&#93;</span><span style="color:#006600; font-weight:bold;">&#41;</span>*<span style="color:#800000;color:#800000;">256</span>+parseInt<span style="color:#006600; font-weight:bold;">&#40;</span>data<span style="color:#006600; font-weight:bold;">&#91;</span><span style="color:#800000;color:#800000;">5</span><span style="color:#006600; font-weight:bold;">&#93;</span><span style="color:#006600; font-weight:bold;">&#41;</span>;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#006600; font-weight:bold;">&#125;</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">return new PassiveSocketInfo<span style="color:#006600; font-weight:bold;">&#40;</span>host, port<span style="color:#006600; font-weight:bold;">&#41;</span>;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#006600; font-weight:bold;">&#125;</span> </div>
</li>
</ol>
</div>
</div>
</div>
<p>
The createPassiveSocket method now takes two extra optional arguments (usingEpsv:Boolean and host:String) and just passes those on to the parseFromResponse method.</p>
<p>Hope this helps anybody looking for EPSV support for <a href="http://maliboo.pl/projects/FlexFTP/" target="_blank">Flex FTP</a>.</p>
<p><em>PS: It's been a while since I added EPSV support, so let me know about any gaps.</em></p>
]]></content:encoded>
			<wfw:commentRss>http://blog.ansuz.nl/index.php/2011/02/07/flex-ftp-epsv-support/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Making your Flash faster / smaller</title>
		<link>http://blog.ansuz.nl/index.php/2010/12/23/making-your-flash-faster-smaller/</link>
		<comments>http://blog.ansuz.nl/index.php/2010/12/23/making-your-flash-faster-smaller/#comments</comments>
		<pubDate>Thu, 23 Dec 2010 17:09:38 +0000</pubDate>
		<dc:creator>Wijnand</dc:creator>
				<category><![CDATA[Random]]></category>

		<guid isPermaLink="false">http://blog.ansuz.nl/?p=248</guid>
		<description><![CDATA[Lately I've been looking into optimizing SWF in both speed in file size, below is a list of interesting projects I came across. Optimizers / disassemblers Azoth: http://www.buraks.com/azoth/ Yogda: http://www.yogda.com/ Apparat: http://code.google.com/p/apparat/ / TDSI: http://blog.joa-ebert.com/2009/08/05/turbodieselsportinjection/ / Reducer: http://blog.joa-ebert.com/2009/08/08/reducer/ Flasm (AS2): &#8230; <a href="http://blog.ansuz.nl/index.php/2010/12/23/making-your-flash-faster-smaller/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>Lately I've been looking into optimizing SWF in both speed in file size, below is a list of interesting projects I came across.</p>
<p><strong>Optimizers / disassemblers</strong></p>
<ul>
<li> Azoth: <a href="http://www.buraks.com/azoth/" target="_blank">http://www.buraks.com/azoth/</a></li>
<li> Yogda: <a href="http://www.yogda.com/" target="_blank">http://www.yogda.com/</a></li>
<li> Apparat: <a href="http://code.google.com/p/apparat/" target="_blank">http://code.google.com/p/apparat/</a> / TDSI: <a href="http://blog.joa-ebert.com/2009/08/05/turbodieselsportinjection/" target="_blank">http://blog.joa-ebert.com/2009/08/05/turbodieselsportinjection/</a> / Reducer: <a href="http://blog.joa-ebert.com/2009/08/08/reducer/" target="_blank">http://blog.joa-ebert.com/2009/08/08/reducer/</a></li>
<li> Flasm (AS2): <a href="http://www.nowrap.de/flasm.html" target="_blank">http://www.nowrap.de/flasm.html</a></li>
<li> RABCDAsm (AS3): <a href="https://github.com/CyberShadow/RABCDAsm" target="_blank">https://github.com/CyberShadow/RABCDAsm</a> and the reason why RABCDAsm was born: <a href="http://leethax.net/facebook/bejeweledblitz/" target="_blank">http://leethax.net/facebook/bejeweledblitz/</a></li>
<li>AS3 Sorcerer: <a href="http://www.as3sorcerer.com/" target="_blank">http://www.as3sorcerer.com/</a></li>
</ul>
<p><strong>Compiler</strong></p>
<ul>
<li> Flex compiler source: <a href="http://opensource.adobe.com/svn/opensource/flex/sdk/branches/4.0.0/modules/compiler/src/" target="_blank">http://opensource.adobe.com/svn/opensource/flex/sdk/branches/4.0.0/modules/compiler/src/</a></li>
<li> Good read about how MXMLC works: <a href="http://stopcoding.wordpress.com/2008/04/19/understanding-the-flex-compiler/" target="_blank">http://stopcoding.wordpress.com/2008/04/19/understanding-the-flex-compiler/</a></li>
<li> AVM2 instructions: <a href="http://www.anotherbigidea.com/javaswf/avm2/AVM2Instructions.html" target="_blank">http://www.anotherbigidea.com/javaswf/avm2/AVM2Instructions.html</a></li>
<li> Tamarin (AVM2 project): <a href="http://www.mozilla.org/projects/tamarin/" target="_blank">http://www.mozilla.org/projects/tamarin/</a></li>
</ul>
<p><strong>Faster compilation</strong></p>
<ul>
<li> Hellfire: <a href="http://bytecode-workshop.com/" target="_blank">http://bytecode-workshop.com/</a></li>
<li> Haxe: <a href="http://haxe.org/" target="_blank">http://haxe.org/</a> (Acclaimed much faster compilation than MXMLC)</li>
</ul>
<p>AS3 Language Specification: <a href="http://livedocs.adobe.com/specs/actionscript/3/wwhelp/wwhimpl/js/html/wwhelp.htm" target="_blank">http://livedocs.adobe.com/specs/actionscript/3/wwhelp/wwhimpl/js/html/wwhelp.htm</a></p>
<p>I'm sure there are some projects I missed... Please do let me know about any good ones I omitted.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.ansuz.nl/index.php/2010/12/23/making-your-flash-faster-smaller/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Flex FTP Make Directory</title>
		<link>http://blog.ansuz.nl/index.php/2010/08/18/flex-ftp-make-directory/</link>
		<comments>http://blog.ansuz.nl/index.php/2010/08/18/flex-ftp-make-directory/#comments</comments>
		<pubDate>Wed, 18 Aug 2010 11:45:58 +0000</pubDate>
		<dc:creator>Wijnand</dc:creator>
				<category><![CDATA[ActionScript 3.0]]></category>
		<category><![CDATA[Air]]></category>
		<category><![CDATA[Flex]]></category>
		<category><![CDATA[flex ftp]]></category>
		<category><![CDATA[FlexFTP]]></category>
		<category><![CDATA[ftp]]></category>

		<guid isPermaLink="false">http://blog.ansuz.nl/?p=243</guid>
		<description><![CDATA[I'm messing around with Flex FTP at the moment and found that there is no way yet to create a directory on the FTP server. I had a quick look through the code on how the other FTP actions were &#8230; <a href="http://blog.ansuz.nl/index.php/2010/08/18/flex-ftp-make-directory/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>I'm messing around with <a href="http://maliboo.pl/projects/FlexFTP/" target="_blank">Flex FTP</a> at the moment and found that there is no way yet to create a directory on the FTP server. I had a quick look through the code on how the other FTP actions were implemented. Being surprised with the nice setup of the code I had quite easily added the "make directory" action and got it working properly. You can download my MakeDirInv class here: <a href="http://ansuz.nl/toys/randomcode/MakeDirInv.as" target="_blank">http://ansuz.nl/toys/randomcode/MakeDirInv.as</a><br />
All you need to do after that is patch the FTPClient class by adding the following method.</p>
<div class="igBar"><span id="lactionscript-35"><a href="#" onclick="javascript:showPlainTxt('actionscript-35'); return false;">PLAIN TEXT</a></span></div>
<div class="syntax_hilite"><span class="langName">Actionscript:</span>
<div id="actionscript-35">
<div class="actionscript">
<ol>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #808080; font-style: italic;">/**</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #808080; font-style: italic;">* Creates a directory on the remote host.</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #808080; font-style: italic;">*</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #808080; font-style: italic;">* @param newDirName The name of the new directory to create.</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #808080; font-style: italic;">* @param parentDir (Optional) The directory to create the new directory in.</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #808080; font-style: italic;">*/</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #0066CC;">public</span> <span style="color: #000000; font-weight: bold;">function</span> makeDir<span style="color: #66cc66;">&#40;</span>newDirName:<span style="color: #0066CC;">String</span>, parentDir:<span style="color: #0066CC;">String</span> = <span style="color: #ff0000;">"/"</span><span style="color: #66cc66;">&#41;</span>:<span style="color: #0066CC;">void</span> <span style="color: #66cc66;">&#123;</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #0066CC;">trace</span><span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">"FTPClient.makeDir(newDirName, parentDir)"</span><span style="color: #66cc66;">&#41;</span>;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">invoke<span style="color: #66cc66;">&#40;</span><span style="color: #000000; font-weight: bold;">new</span> MakeDirInv<span style="color: #66cc66;">&#40;</span><span style="color: #0066CC;">this</span>, newDirName, parentDir<span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span>;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #66cc66;">&#125;</span> </div>
</li>
</ol>
</div>
</div>
</div>
<p></p>
<p>Once you've done that, you're ready to create directories on the FTP server you're connected to, see the example below.</p>
<div class="igBar"><span id="lactionscript-36"><a href="#" onclick="javascript:showPlainTxt('actionscript-36'); return false;">PLAIN TEXT</a></span></div>
<div class="syntax_hilite"><span class="langName">Actionscript:</span>
<div id="actionscript-36">
<div class="actionscript">
<ol>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">ftpClient.<span style="color: #006600;">addEventListener</span><span style="color: #66cc66;">&#40;</span>FTPEvent.<span style="color: #006600;">CREATE_DIR</span>, dirCreatedHandler<span style="color: #66cc66;">&#41;</span>;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">ftpClient.<span style="color: #006600;">makeDir</span><span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">"myNewDir"</span>, <span style="color: #ff0000;">"/someSubDir/"</span><span style="color: #66cc66;">&#41;</span>; </div>
</li>
</ol>
</div>
</div>
</div>
<p></p>
<p><em>PS: This isn't fully tested yet, so do let me know if you find some bugs.</em></p>
<p>Links</p>
<ul>
<li><a href="http://maliboo.pl/projects/FlexFTP/" target="_blank">Flex FTP</a></li>
<li><a href="http://ansuz.nl/toys/randomcode/MakeDirInv.as" target="_blank">MakeDirInv class</a></li>
</ul>
]]></content:encoded>
			<wfw:commentRss>http://blog.ansuz.nl/index.php/2010/08/18/flex-ftp-make-directory/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Installing ANT contrib for Eclipse</title>
		<link>http://blog.ansuz.nl/index.php/2010/08/13/installing-ant-contrib-for-eclipse/</link>
		<comments>http://blog.ansuz.nl/index.php/2010/08/13/installing-ant-contrib-for-eclipse/#comments</comments>
		<pubDate>Fri, 13 Aug 2010 11:59:38 +0000</pubDate>
		<dc:creator>Wijnand</dc:creator>
				<category><![CDATA[Random]]></category>
		<category><![CDATA[ant]]></category>
		<category><![CDATA[ant-contrib]]></category>
		<category><![CDATA[contrib]]></category>
		<category><![CDATA[Eclipse]]></category>

		<guid isPermaLink="false">http://blog.ansuz.nl/?p=240</guid>
		<description><![CDATA[A quick step by step guide to installing ANT-contrib for Eclipse (on Windows). Download ANT-contrib: http://sourceforge.net/projects/ant-contrib/files/ Extract the zip to your harddrive, I extracted it to C:/ant-contrib/ Include ANT-contrib in your ANT build file, so you don't have to set &#8230; <a href="http://blog.ansuz.nl/index.php/2010/08/13/installing-ant-contrib-for-eclipse/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>A quick step by step guide to installing ANT-contrib for Eclipse (on Windows).</p>
<ol>
<li>Download ANT-contrib: <a href="http://sourceforge.net/projects/ant-contrib/files/" target="_blank">http://sourceforge.net/projects/ant-contrib/files/</a></li>
<li>Extract the zip to your harddrive, I extracted it to C:/ant-contrib/</li>
<li>Include ANT-contrib in your ANT build file, so you don't have to set it up every time you create a new project. (See XML below)</li>
<li>All done!</li>
</ol>
<p>Additional XML in ANT build script:</p>
<div class="igBar"><span id="lxml-38"><a href="#" onclick="javascript:showPlainTxt('xml-38'); return false;">PLAIN TEXT</a></span></div>
<div class="syntax_hilite"><span class="langName">XML:</span>
<div id="xml-38">
<div class="xml">
<ol>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #ddbb00;">&amp;lt;</span>taskdef resource=&quot;net/sf/antcontrib/antcontrib.properties&quot;<span style="color: #ddbb00;">&amp;gt;</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #ddbb00;">&amp;lt;</span>classpath<span style="color: #ddbb00;">&amp;gt;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #ddbb00;">&amp;lt;</span>pathelement location=&quot;[full path to ant-contrib jar]&quot;/<span style="color: #ddbb00;">&amp;gt;</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #ddbb00;">&amp;lt;</span>/classpath<span style="color: #ddbb00;">&amp;gt;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #ddbb00;">&amp;lt;</span>/taskdef<span style="color: #ddbb00;">&amp;gt;</span> </div>
</li>
</ol>
</div>
</div>
</div>
<p></p>
<p><strong>Links</strong></p>
<ul>
<li><a title="ANT-contrib homepage" href="http://ant-contrib.sourceforge.net/" target="_blank">ANT-contrib homepage</a></li>
</ul>
]]></content:encoded>
			<wfw:commentRss>http://blog.ansuz.nl/index.php/2010/08/13/installing-ant-contrib-for-eclipse/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Some things are null on Win, but not on Mac</title>
		<link>http://blog.ansuz.nl/index.php/2010/07/15/some-things-are-null-on-win-but-not-on-mac/</link>
		<comments>http://blog.ansuz.nl/index.php/2010/07/15/some-things-are-null-on-win-but-not-on-mac/#comments</comments>
		<pubDate>Thu, 15 Jul 2010 08:18:05 +0000</pubDate>
		<dc:creator>Wijnand</dc:creator>
				<category><![CDATA[ActionScript 3.0]]></category>

		<guid isPermaLink="false">http://blog.ansuz.nl/?p=235</guid>
		<description><![CDATA[PLAIN TEXT Actionscript: var myArray:Array = new Array&#40;new SomeObject&#40;&#41;, new SomeObject&#40;&#41;, new SomeObject&#40;&#41;&#41;; // true on Win, false on Mac trace&#40;myArray&#91;3&#93; == null&#41;; Such fun those little differences in the Flash Player!]]></description>
			<content:encoded><![CDATA[<div class="igBar"><span id="lactionscript-40"><a href="#" onclick="javascript:showPlainTxt('actionscript-40'); return false;">PLAIN TEXT</a></span></div>
<div class="syntax_hilite"><span class="langName">Actionscript:</span>
<div id="actionscript-40">
<div class="actionscript">
<ol>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #000000; font-weight: bold;">var</span> myArray:<span style="color: #0066CC;">Array</span> = <span style="color: #000000; font-weight: bold;">new</span> <span style="color: #0066CC;">Array</span><span style="color: #66cc66;">&#40;</span><span style="color: #000000; font-weight: bold;">new</span> SomeObject<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>, <span style="color: #000000; font-weight: bold;">new</span> SomeObject<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>, <span style="color: #000000; font-weight: bold;">new</span> SomeObject<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span>;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #808080; font-style: italic;">// true on Win, false on Mac</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #0066CC;">trace</span><span style="color: #66cc66;">&#40;</span>myArray<span style="color: #66cc66;">&#91;</span><span style="color: #cc66cc;color:#800000;">3</span><span style="color: #66cc66;">&#93;</span> == <span style="color: #000000; font-weight: bold;">null</span><span style="color: #66cc66;">&#41;</span>; </div>
</li>
</ol>
</div>
</div>
</div>
<p></p>
<p>Such fun those little differences in the Flash Player! <img src='http://blog.ansuz.nl/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
]]></content:encoded>
			<wfw:commentRss>http://blog.ansuz.nl/index.php/2010/07/15/some-things-are-null-on-win-but-not-on-mac/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Grazia 3D</title>
		<link>http://blog.ansuz.nl/index.php/2010/03/23/grazia-3d/</link>
		<comments>http://blog.ansuz.nl/index.php/2010/03/23/grazia-3d/#comments</comments>
		<pubDate>Tue, 23 Mar 2010 12:59:26 +0000</pubDate>
		<dc:creator>Wijnand</dc:creator>
				<category><![CDATA[Random]]></category>

		<guid isPermaLink="false">http://blog.ansuz.nl/?p=233</guid>
		<description><![CDATA[I thought this was going to be yet another AR (augmented reality) app, but it is actually quite impressive! Have a look here: http://www.graziadaily.co.uk/graziatv/archive/2010/03/23/video--check-out-grazia-s-3d-walk-in-talking-issue.htm I'm wondering what agency built this one... Source: http://gizmodo.com/5499785/now-womens-mags-are-doing-augmented-reality]]></description>
			<content:encoded><![CDATA[<p>I thought this was going to be yet another AR (augmented reality) app, but it is actually quite impressive! Have a look here: <a href="http://www.graziadaily.co.uk/graziatv/archive/2010/03/23/video--check-out-grazia-s-3d-walk-in-talking-issue.htm " target="_blank">http://www.graziadaily.co.uk/graziatv/archive/2010/03/23/video--check-out-grazia-s-3d-walk-in-talking-issue.htm </a></p>
<p>I'm wondering what agency built this one...</p>
<p><strong>Source:</strong> <a href="http://gizmodo.com/5499785/now-womens-mags-are-doing-augmented-reality" target="_blank">http://gizmodo.com/5499785/now-womens-mags-are-doing-augmented-reality</a></p>
]]></content:encoded>
			<wfw:commentRss>http://blog.ansuz.nl/index.php/2010/03/23/grazia-3d/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>De MonsterDebugger</title>
		<link>http://blog.ansuz.nl/index.php/2010/03/11/de-monsterdebugger/</link>
		<comments>http://blog.ansuz.nl/index.php/2010/03/11/de-monsterdebugger/#comments</comments>
		<pubDate>Thu, 11 Mar 2010 10:51:14 +0000</pubDate>
		<dc:creator>Wijnand</dc:creator>
				<category><![CDATA[ActionScript 3.0]]></category>
		<category><![CDATA[Air]]></category>
		<category><![CDATA[Flex]]></category>

		<guid isPermaLink="false">http://blog.ansuz.nl/?p=229</guid>
		<description><![CDATA[I'm always looking for a nice debugger to use on the fly, the "De MonsterDebugger" looks really nice. De MonsterDebugger is an open source debugger for Adobe Flash, Flex and AIR. De MonsterDebugger is made in Flex and AIR by &#8230; <a href="http://blog.ansuz.nl/index.php/2010/03/11/de-monsterdebugger/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>I'm always looking for a nice debugger to use on the fly, the "De MonsterDebugger" looks really nice.</p>
<blockquote><p>De MonsterDebugger is an open source debugger for Adobe Flash, Flex and AIR. De MonsterDebugger is made in Flex and AIR by design studio De Monsters.</p></blockquote>
<p>One of the nicest features in my opinion is the <a href="http://www.demonsterdebugger.com/features/liveediting" target="_blank">live editing</a> of properties, very handy when fiddling to position elements correctly.</p>
<p><strong>Links:</strong></p>
<ul>
<li>Homepage: <a href="http://www.demonsterdebugger.com/ " target="_blank">http://www.demonsterdebugger.com/ </a></li>
<li>Download: <a href="http://www.demonsterdebugger.com/download" target="_blank">http://www.demonsterdebugger.com/download</a></li>
</ul>
]]></content:encoded>
			<wfw:commentRss>http://blog.ansuz.nl/index.php/2010/03/11/de-monsterdebugger/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Video Converter</title>
		<link>http://blog.ansuz.nl/index.php/2010/01/22/video-converter/</link>
		<comments>http://blog.ansuz.nl/index.php/2010/01/22/video-converter/#comments</comments>
		<pubDate>Fri, 22 Jan 2010 13:12:00 +0000</pubDate>
		<dc:creator>Wijnand</dc:creator>
				<category><![CDATA[Random]]></category>

		<guid isPermaLink="false">http://blog.ansuz.nl/?p=227</guid>
		<description><![CDATA[A colleague pointed WinFF out to me, a nice GUI for FFmpeg. No more worrying about command line options, long life laziness! PS: No need to download FFmpeg, it comes packaged with WinFF.]]></description>
			<content:encoded><![CDATA[<p>A colleague pointed <a href="http://winff.org/html_new/" target="_blank">WinFF</a> out to me, a nice GUI for <a href="http://ffmpeg.org/index.html" target="_blank">FFmpeg</a>. No more worrying about command line options, long life laziness! <img src='http://blog.ansuz.nl/wp-includes/images/smilies/icon_biggrin.gif' alt=':D' class='wp-smiley' /> </p>
<p>PS: No need to download FFmpeg, it comes packaged with WinFF.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.ansuz.nl/index.php/2010/01/22/video-converter/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>wmode=&#8221;transparent&#8221;</title>
		<link>http://blog.ansuz.nl/index.php/2010/01/21/wmodetransparent/</link>
		<comments>http://blog.ansuz.nl/index.php/2010/01/21/wmodetransparent/#comments</comments>
		<pubDate>Thu, 21 Jan 2010 15:08:55 +0000</pubDate>
		<dc:creator>Wijnand</dc:creator>
				<category><![CDATA[HTML / CSS]]></category>

		<guid isPermaLink="false">http://blog.ansuz.nl/?p=223</guid>
		<description><![CDATA[I never knew/realised this, but it's very useful to know: The background of a Flash movie can be set to transparent. This allows the background color or image of the HTML page that contains the Flash movie to show through &#8230; <a href="http://blog.ansuz.nl/index.php/2010/01/21/wmodetransparent/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>I never knew/realised this, but it's very useful to know:</p>
<blockquote><p>The background of a Flash movie can be set to transparent. This allows the background color or image of the HTML page that contains the Flash movie to show through and <strong>allows the layering of Flash content with DHTML content</strong>.</p></blockquote>
<p>Very useful when your Flash is on a layer in HTML that could be covered by something else when you're scrolling the page.</p>
<p>Wmode not set:</p>
<div class="wp-caption alignnone" style="width: 410px"><img title="Wmode not set" src="http://blog.ansuz.nl/tests/wmode/wmode_normal.jpg" alt="Wmode not set" width="400" height="276" /><p class="wp-caption-text">Wmode not set</p></div>
<p>Wmode set to "transparent":</p>
<div class="wp-caption alignnone" style="width: 410px"><img title="wmode set to transparent" src="http://blog.ansuz.nl/tests/wmode/wmode_transparent.jpg" alt="wmode set to transparent" width="400" height="276" /><p class="wp-caption-text">wmode set to transparent</p></div>
<p><strong>Source:</strong> <a href="http://kb2.adobe.com/cps/142/tn_14201.html" target="_blank">Adobe TechNote</a></p>
<p><em>PS: Never mind the awesome (ahem) colours, this was just a quick test.</em> <img src='http://blog.ansuz.nl/wp-includes/images/smilies/icon_wink.gif' alt=';)' class='wp-smiley' /> </p>
]]></content:encoded>
			<wfw:commentRss>http://blog.ansuz.nl/index.php/2010/01/21/wmodetransparent/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Phidgets / Arduino</title>
		<link>http://blog.ansuz.nl/index.php/2010/01/20/phidgets-arduino/</link>
		<comments>http://blog.ansuz.nl/index.php/2010/01/20/phidgets-arduino/#comments</comments>
		<pubDate>Wed, 20 Jan 2010 13:10:21 +0000</pubDate>
		<dc:creator>Wijnand</dc:creator>
				<category><![CDATA[ActionScript 3.0]]></category>
		<category><![CDATA[Flex]]></category>
		<category><![CDATA[Random]]></category>

		<guid isPermaLink="false">http://blog.ansuz.nl/?p=219</guid>
		<description><![CDATA[I'd love to have some time to mess around with a Phidgets or Arduino board, it looks like a lot of fun! Using Flash to control something analog/physical!]]></description>
			<content:encoded><![CDATA[<p>I'd love to have some time to mess around with a <a href="http://www.phidgets.com/index.php" target="_blank">Phidgets</a> or <a href="http://arduino.cc/" target="_blank">Arduino</a> board, it looks like a lot of fun! Using Flash to control something analog/physical! <img src='http://blog.ansuz.nl/wp-includes/images/smilies/icon_biggrin.gif' alt=':D' class='wp-smiley' /> </p>
]]></content:encoded>
			<wfw:commentRss>http://blog.ansuz.nl/index.php/2010/01/20/phidgets-arduino/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Flex IRC Client</title>
		<link>http://blog.ansuz.nl/index.php/2010/01/14/flex-irc-client/</link>
		<comments>http://blog.ansuz.nl/index.php/2010/01/14/flex-irc-client/#comments</comments>
		<pubDate>Thu, 14 Jan 2010 12:00:16 +0000</pubDate>
		<dc:creator>Wijnand</dc:creator>
				<category><![CDATA[ActionScript 3.0]]></category>
		<category><![CDATA[Flex]]></category>

		<guid isPermaLink="false">http://blog.ansuz.nl/?p=214</guid>
		<description><![CDATA[Just came across this when browsing around a bit. This Flex IRC client is a port of the Java-based PircBot. Flex IRC Client aims to be a Flex / Flash based IRC Client. Currently most browser-based chat solutions are either &#8230; <a href="http://blog.ansuz.nl/index.php/2010/01/14/flex-irc-client/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>Just came across this when browsing around a bit. This Flex IRC client is a port of the Java-based <a href="http://code.google.com/p/flexircclient/wiki/PircBot">PircBot</a>.</p>
<blockquote><p>Flex IRC Client aims to be a Flex / Flash based IRC Client. Currently most browser-based chat solutions are either proprietary or applets. Flex IRC Client wants to bring the power of IRC to the majority of the Internet-users without requiring a download or an install.</p></blockquote>
<p>I know this client is still under development, but it could really do with a window showing some progress when connecting to a server. Also, a proxy of sorts would be nice since I get a lot of Security Errors when trying to connect to a server: <em>"SecurityErrorEvent type="securityError" bubbles=false cancelable=false eventPhase=2 text="Error #2048: Security sandbox violation: http://ansuz.nl/toys/irc/FlexIRCClient.swf cannot load data from irc.efnet.nl:6667.""</em>, probably due to no cross-domain policies being set on the IRC servers. Connecting works when running this locally <img src='http://blog.ansuz.nl/wp-includes/images/smilies/icon_wink.gif' alt=';)' class='wp-smiley' /> </p>
<p><strong>Links</strong></p>
<ul>
<li>Project page: <a href="http://code.google.com/p/flexircclient/" target="_blank">http://code.google.com/p/flexircclient/</a></li>
<li>Demo: <a href="http://ansuz.nl/toys/irc/" target="_blank">http://ansuz.nl/toys/irc/</a></li>
<li>Server: irc.servercentral.net</li>
<li>Port: 6667</li>
<li>Channel: #flexnet</li>
</ul>
]]></content:encoded>
			<wfw:commentRss>http://blog.ansuz.nl/index.php/2010/01/14/flex-irc-client/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

